<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Wi-Fi Connection Manager Library: Overview</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="cypress_logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Wi-Fi Connection Manager Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">Overview </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p >This library provides a set of APIs that can be used to establish and monitor Wi-Fi connections on Infineon platforms that support Wi-Fi connectivity. WCM library APIs are easy to use; in addition, the library provides additional features such as Wi-Fi Protected Setup (WPS) and connection monitoring.</p>
<h1><a class="anchor" id="section_multi_core_architecture"></a>
Multi-core architecture and virtual API support</h1>
<p >The library supports multi-core architecture by making a subset of APIs available as virtual APIs. The virtualization of the WCM library helps to access the WCM APIs defined in one core from the other core using Inter Process Communication (IPC). WCM can now be run on two cores simultaneously, with one core containing the full connectivity stack (primary core) and the other core containing the subset of virtual-only APIs (secondary core). The virtual APIs pipe the API requests over IPC to the primary core where the API is actually executed and the result is passed back to the secondary core. This virtualization abstracts out the implementation details and complexity of IPC, thus making multi-core connectivity application development simple.</p>
<p >For more information on virtualization, see the <a href="https://github.com/Infineon/virtual-connectivity-manager">Virtual Connectivity Manager</a> library.</p>
<h1><a class="anchor" id="section_features"></a>
Features and functionality</h1>
<p >The current implementation has the following features and functionality:</p><ul>
<li>Supports WPA3 personal network security</li>
<li>Supports STA, SoftAP, and Concurrent (simultaneous SoftAP + STA) modes</li>
<li>Support for Wi-Fi Protected Setup (WPS) - Enrollee role</li>
<li>Exposes Wi-Fi APIs to scan, join, and leave the Wi-Fi network</li>
<li>Connection monitoring: Monitors active connections and link events. Automatically reconnects to the AP if the connection with the AP is lost intermittently. Notifies the connection state change through event the notification registration mechanism.</li>
<li>Supports connectivity applications based on either FreeRTOS, lwIP, mbed TLS combination or ThreadX, NetX Duo, NetX Secure combination(Currently only supported on CYW955913EVK-01)</li>
<li>The library is built on top of the abstraction-rtos library that provides RTOS abstraction API for FreeRTOS and ThreadX</li>
<li>Supports multi-core architecture by providing the following APIs as virtual APIs which can be invoked from another core:<ul>
<li>cy_wcm_is_connected_to_ap</li>
<li>cy_wcm_register_event_callback</li>
<li>cy_wcm_deregister_event_callback</li>
</ul>
</li>
</ul>
<h1><a class="anchor" id="section_supported_platforms"></a>
Supported platforms</h1>
<p >This library and its features are supported on the following Infineon platforms:</p><ul>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8cproto-062-4343w/">PSoC&trade; 6 Wi-Fi BT prototyping kit (CY8CPROTO-062-4343W)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062s2-43012/">PSoC&trade; 62S2 Wi-Fi BT pioneer kit (CY8CKIT-062S2-43012)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-062-wifi-bt/">PSoC&trade; 6 WiFi-BT pioneer kit (CY8CKIT-062-WiFi-BT)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/">PSoC&trade; 62S2 evaluation kit (CY8CEVAL-062S2-LAI-4373M2)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cyw954907aeval1f/">CYW954907AEVAL1F Evaluation Kit(CYW954907AEVAL1F)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cyw943907aeval1f/">CYW943907AEVAL1F Evaluation Kit(CYW943907AEVAL1F)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/">PSoC&trade; 62S2 evaluation kit (CY8CEVAL-062S2-MUR-43439M2)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/">XMC7200D-E272K8384 kit (KIT_XMC72_EVK_MUR_43439M2)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/">PSoC&trade; 62S2 evaluation kit (CY8CEVAL-062S2-CYW43022CUB)</a></li>
<li><a href="https://www.infineon.com/CYW955913EVK-01">CYW955913EVK-01 Wi-Fi Bluetooth&reg; Prototyping Kit (CYW955913EVK-01)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/cy8ceval-062s2/">PSoC&trade; 62S2 evaluation kit (CY8CEVAL-062S2-CYW955513SDM2WLIPA)</a> <dl class="section note"><dt>Note</dt><dd>Virtual APIs are supported on all PSoC 62 devices, but they have only been tested on the CY8CEVAL-062S2-MUR-43439M2 kit.</dd></dl>
</li>
</ul>
<h1><a class="anchor" id="section_dependencies"></a>
Dependent libraries</h1>
<p >This library is bundled in <a href="https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls">wifi-core-freertos-lwip-mbedtls</a> by default. The wifi-core-freertos-lwip-mbedtls library helps code examples to fetch all the components needed to enable Wi-Fi connectivity.</p><ul>
<li>For CYW955913EVK-01 this library will be bundled in <a href="https://github.com/Infineon/wifi-core-threadx-cat5">wifi-core-threadx-cat5</a>.</li>
</ul>
<p >If virtual APIs are to be used, it additionally depends on <a href="https://github.com/Infineon/virtual-connectivity-manager">Virtual Connectivity Manager</a> library.</p>
<h1><a class="anchor" id="section_integration"></a>
Quick start</h1>
<ul>
<li>To use wifi-connection-manager library for FreeRTOS, lwIP, mbed TLS combination, the application should pull the <a href="https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls">wifi-core-freertos-lwip-mbedtls</a> library which will internally pull wifi-connection-manager, FreeRTOS, lwIP, mbed TLS, and other dependent modules.</li>
<li>To pull wifi-core-freertos-lwip-mbedtls create the following .mtb file in deps folder.<ul>
<li>wifi-core-freertos-lwip-mbedtls.mtb: <a href="https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls#latest-v1.X#$$ASSET_REPO$$/wifi-core-freertos-lwip-mbedtls/latest-v1.X">https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls#latest-v1.X#$$ASSET_REPO$$/wifi-core-freertos-lwip-mbedtls/latest-v1.X</a></li>
</ul>
</li>
<li>To use wifi-connection-manager library for ThreadX, NetX Duo, NetX Secure combination, the application should pull the <a href="https://github.com/Infineon/wifi-core-threadx-cat5">wifi-core-threadx-cat5</a> library which will internally pull wifi-connection-manager and other dependent modules.</li>
<li>To pull wifi-core-threadx-cat5 create the following .mtb file in deps folder.<ul>
<li>wifi-core-threadx-cat5.mtb: <a href="https://github.com/Infineon/wifi-core-threadx-cat5#latest-v1.X#$$ASSET_REPO$$/wifi-core-threadx-cat5/latest-v1.X">https://github.com/Infineon/wifi-core-threadx-cat5#latest-v1.X#$$ASSET_REPO$$/wifi-core-threadx-cat5/latest-v1.X</a></li>
</ul>
</li>
<li>For existing Wi-Fi Connection Manager version 2.x users, a <a href="https://github.com/Infineon/wifi-connection-manager/blob/master/porting_guide.md">porting guide</a> is available to migrate to Wi-Fi Connection Manager version 3.0.</li>
<li>Review the pre-defined configuration files bundled with the wifi-core-freertos-lwip-mbedtls library for FreeRTOS, lwIP, and mbed TLS, and make adjustments. See the quick start section in <a href="https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls/blob/master/README.md">README.md</a>.</li>
<li>Define a set of COMPONENTS in the code example project's Makefile for this library.<ul>
<li>For FreeRTOS, lwIP, Mbed TLS combination see the quick start section in <a href="https://github.com/Infineon/wifi-core-freertos-lwip-mbedtls/blob/master/README.md">README.md</a>.</li>
<li>For ThreadX, NetX Duo, NetX Secure combination see the quick start section in <a href="https://github.com/Infineon/wifi-core-threadx-cat5/blob/master/README.md">README.md</a>.</li>
</ul>
</li>
<li>WPS is disabled by default. WPS uses Mbed TLS security stack. Enable the following components for WPS: <div class="fragment"><div class="line">COMPONENTS+=WPS MBEDTLS</div>
</div><!-- fragment --></li>
<li>The WCM library disables all the debug log messages by default. To enable log messages, the application must perform the following:<ol type="1">
<li>Add the <em>ENABLE_WCM_LOGS</em> macro to the <em>DEFINES</em> in the code example's Makefile. The Makefile entry would look like as follows: <div class="fragment"><div class="line">DEFINES+=ENABLE_WCM_LOGS</div>
</div><!-- fragment --></li>
<li>Call the <em>cy_log_init()</em> function provided by the <em>cy-log</em> module. cy-log is part of the <em>connectivity-utilities</em> library. See *<a href="https://Infineon.github.io/connectivity-utilities/api_reference_manual/html/group__logging__utils.html">connectivity-utilities library API documentation</a>.<ul>
<li>To enable logs in a dual core application please refer to <a href="https://github.com/Infineon/virtual-connectivity-manager/blob/main/README.md#enable-logs-in-dual-core-application">Enable logs in dual core application</a> section in Virtual Connectivity Manager.</li>
</ul>
</li>
</ol>
</li>
</ul>
<h2><a class="anchor" id="To"></a>
use virtual APIs</h2>
<ul>
<li>To use WCM virtual APIs, pull <a href="https://github.com/Infineon/virtual-connectivity-manager">Virtual Connectivity Manager</a> library. Create the following *.mtb* file to pull the library<ul>
<li>virtual-connectivity-manager.mtb: <a href="https://github.com/Infineon/virtual-connectivity-manager#latest-v1.X#$$ASSET_REPO$$/virtual-connectivity-manager/latest-v1.X">https://github.com/Infineon/virtual-connectivity-manager#latest-v1.X#$$ASSET_REPO$$/virtual-connectivity-manager/latest-v1.X</a></li>
</ul>
</li>
<li><dl class="section note"><dt>Note</dt><dd>To use WCM APIs in a multi-core environment, applications on both the cores should include WCM and VCM libraries.</dd></dl>
</li>
<li>Define the following compile-time macro in the primary core application's Makefile: <div class="fragment"><div class="line">DEFINES+=ENABLE_MULTICORE_CONN_MW</div>
</div><!-- fragment --></li>
<li>Define the following compile-time macros in the secondary core application's Makefile: <div class="fragment"><div class="line">DEFINES+=ENABLE_MULTICORE_CONN_MW USE_VIRTUAL_API</div>
</div><!-- fragment --></li>
<li>Call the <em>cy_vcm_init()</em> function provided by the VCM library from the application on both cores, before invoking the virtual WCM APIs. See <a href="https://infineon.github.io/virtual-connectivity-manager/api_reference_manual/html/index.html">Virtual Connectivity Manager API documentation</a>. <dl class="section note"><dt>Note</dt><dd>- To ensure that the VCM initialization is synchronized, the project which boots first(i.e CM0+ project in case of psoc62) must call <em>cy_vcm_init</em> before bringing up the second project(i.e CM4 project in case of psoc62). </dd>
<dd>
- The first project must initialize VCM, by passing <em>config.hal_resource_opt</em> as <em>CY_VCM_CREATE_HAL_RESOURCE</em> in <em>cy_vcm_init</em>. The second project must pass <em>config.hal_resource_opt</em> as <em>CY_VCM_USE_HAL_RESOURCE</em>.</dd></dl>
</li>
</ul>
<h1><a class="anchor" id="section_code_snippet"></a>
Code snippets</h1>
<h2><a class="anchor" id="snip1"></a>
Snippet 1: Scan for all APs</h2>
<p >The following snippet demonstrates how to initialize the Wi-Fi device and network stack, and start scanning for APs without any filters. The scan_callback receives the scan results and prints them over the serial terminal.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/* Scan callback function */</span></div>
<div class="line"><span class="keywordtype">void</span> scan_callback(<a class="code hl_struct" href="structcy__wcm__scan__result__t.html">cy_wcm_scan_result_t</a> *result_ptr, <span class="keywordtype">void</span> *user_data, <a class="code hl_enumeration" href="group__group__wcm__enums.html#ga24a4ed65a9261c45abc8aa697eb2b8a2">cy_wcm_scan_status_t</a> status)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">/* Print the scan result only when scan is incomplete because on scan completion</span></div>
<div class="line"><span class="comment">     * the contents of result_ptr are empty.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">if</span> (status == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24a4ed65a9261c45abc8aa697eb2b8a2a01103577816da05a7b2b9521576c3c6e">CY_WCM_SCAN_INCOMPLETE</a>)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot; %-32s     %4d     %2d\n&quot;</span>,</div>
<div class="line">               result_ptr-&gt;<a class="code hl_variable" href="structcy__wcm__scan__result__t.html#adcf0e592c5ea946e9ce821b6a13262d4">SSID</a>, result_ptr-&gt;<a class="code hl_variable" href="structcy__wcm__scan__result__t.html#ac2d508f92bd91a322db54d59f9c42ce5">signal_strength</a>, result_ptr-&gt;<a class="code hl_variable" href="structcy__wcm__scan__result__t.html#a2c07eb8659b1c9e79cd41b141ab7a52d">channel</a>);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_scan_without_filter()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device as a STA.*/</span></div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> config = {.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>};</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device, Wi-Fi transport, and lwIP network stack.*/</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;config);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_init failed....!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">/* Filter is set to NULL.*/</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gae0f0b5f3e6138bfdae943e9f7b16aa07">cy_wcm_start_scan</a>(scan_callback, NULL, NULL);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_start_scan failed....!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="agroup__group__wcm__enums_html_ga24a4ed65a9261c45abc8aa697eb2b8a2"><div class="ttname"><a href="group__group__wcm__enums.html#ga24a4ed65a9261c45abc8aa697eb2b8a2">cy_wcm_scan_status_t</a></div><div class="ttdeci">cy_wcm_scan_status_t</div><div class="ttdoc">Enumeration of scan status.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:251</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga24a4ed65a9261c45abc8aa697eb2b8a2a01103577816da05a7b2b9521576c3c6e"><div class="ttname"><a href="group__group__wcm__enums.html#gga24a4ed65a9261c45abc8aa697eb2b8a2a01103577816da05a7b2b9521576c3c6e">CY_WCM_SCAN_INCOMPLETE</a></div><div class="ttdeci">@ CY_WCM_SCAN_INCOMPLETE</div><div class="ttdoc">Scan is in progress; more scan results will be returned.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:252</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208"><div class="ttname"><a href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a></div><div class="ttdeci">@ CY_WCM_INTERFACE_TYPE_STA</div><div class="ttdoc">STA or client interface.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:232</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga888428a2325f131528f7447e894002eb"><div class="ttname"><a href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a></div><div class="ttdeci">cy_rslt_t cy_wcm_init(cy_wcm_config_t *config)</div><div class="ttdoc">Initializes the WCM.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_gae0f0b5f3e6138bfdae943e9f7b16aa07"><div class="ttname"><a href="group__group__wcm__functions.html#gae0f0b5f3e6138bfdae943e9f7b16aa07">cy_wcm_start_scan</a></div><div class="ttdeci">cy_rslt_t cy_wcm_start_scan(cy_wcm_scan_result_callback_t scan_callback, void *user_data, cy_wcm_scan_filter_t *scan_filter)</div><div class="ttdoc">Performs a Wi-Fi network scan.</div></div>
<div class="ttc" id="astructcy__wcm__config__t_html"><div class="ttname"><a href="structcy__wcm__config__t.html">cy_wcm_config_t</a></div><div class="ttdoc">Structure used to pass WCM configuration to cy_wcm_init.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:427</div></div>
<div class="ttc" id="astructcy__wcm__config__t_html_ab516902a377cf7b51d1965183c0bfc2f"><div class="ttname"><a href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">cy_wcm_config_t::interface</a></div><div class="ttdeci">cy_wcm_interface_t interface</div><div class="ttdoc">Interface type.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:428</div></div>
<div class="ttc" id="astructcy__wcm__scan__result__t_html"><div class="ttname"><a href="structcy__wcm__scan__result__t.html">cy_wcm_scan_result_t</a></div><div class="ttdoc">Structure used for storing scan results.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:510</div></div>
<div class="ttc" id="astructcy__wcm__scan__result__t_html_a2c07eb8659b1c9e79cd41b141ab7a52d"><div class="ttname"><a href="structcy__wcm__scan__result__t.html#a2c07eb8659b1c9e79cd41b141ab7a52d">cy_wcm_scan_result_t::channel</a></div><div class="ttdeci">uint8_t channel</div><div class="ttdoc">Radio channel that the AP beacon was received on.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:517</div></div>
<div class="ttc" id="astructcy__wcm__scan__result__t_html_ac2d508f92bd91a322db54d59f9c42ce5"><div class="ttname"><a href="structcy__wcm__scan__result__t.html#ac2d508f92bd91a322db54d59f9c42ce5">cy_wcm_scan_result_t::signal_strength</a></div><div class="ttdeci">int16_t signal_strength</div><div class="ttdoc">RSSI in dBm.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:513</div></div>
<div class="ttc" id="astructcy__wcm__scan__result__t_html_adcf0e592c5ea946e9ce821b6a13262d4"><div class="ttname"><a href="structcy__wcm__scan__result__t.html#adcf0e592c5ea946e9ce821b6a13262d4">cy_wcm_scan_result_t::SSID</a></div><div class="ttdeci">cy_wcm_ssid_t SSID</div><div class="ttdoc">SSID (i.e., name of the AP).</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:511</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip2"></a>
Snippet 2: Scan for a specific AP</h2>
<p >The following snippet demonstrates the configuration of a scan filter to filter by the SSID provided and start a scan. The scan_callback receives the scan results and prints them over the serial terminal.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_scan_with_ssid_filter()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__scan__filter__t.html">cy_wcm_scan_filter_t</a> scan_filter;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* SSID value which is used to filter the scan results.*/</span></div>
<div class="line">    <span class="keyword">static</span> <span class="keyword">const</span> <a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga1ebac1800928741a07555a14539f3748">cy_wcm_ssid_t</a> ssid = <span class="stringliteral">&quot;SSID&quot;</span>;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Configure the scan filter specified by the variable ssid.*/</span></div>
<div class="line">    scan_filter.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#a019063e2d7ac38f8123fa6181afc45b8">mode</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga568b22d5d446e751f62efe4eb021d451ae6a7c2fd74a727b9d1f3e0261533a7c4">CY_WCM_SCAN_FILTER_TYPE_SSID</a>;</div>
<div class="line">    memcpy(scan_filter.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#aa5503177afe2830f94a4e09ac6e675f3">param</a>.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#ad8d3cb78527ac618f0a3994ac497cc35">SSID</a>, ssid, <span class="keyword">sizeof</span>(<a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga1ebac1800928741a07555a14539f3748">cy_wcm_ssid_t</a>));</div>
<div class="line">    printf(<span class="stringliteral">&quot;\n---------------------------------------------------------------------------------\n&quot;</span></div>
<div class="line">           <span class="stringliteral">&quot;                  SSID                  RSSI   Channel      \n&quot;</span></div>
<div class="line">           <span class="stringliteral">&quot;---------------------------------------------------------------------------------\n&quot;</span>);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gae0f0b5f3e6138bfdae943e9f7b16aa07">cy_wcm_start_scan</a>(scan_callback, NULL, &amp;scan_filter);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_start_scan failed....!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga568b22d5d446e751f62efe4eb021d451ae6a7c2fd74a727b9d1f3e0261533a7c4"><div class="ttname"><a href="group__group__wcm__enums.html#gga568b22d5d446e751f62efe4eb021d451ae6a7c2fd74a727b9d1f3e0261533a7c4">CY_WCM_SCAN_FILTER_TYPE_SSID</a></div><div class="ttdeci">@ CY_WCM_SCAN_FILTER_TYPE_SSID</div><div class="ttdoc">SSID-based scan filtering.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:354</div></div>
<div class="ttc" id="agroup__group__wcm__typedefs_html_ga1ebac1800928741a07555a14539f3748"><div class="ttname"><a href="group__group__wcm__typedefs.html#ga1ebac1800928741a07555a14539f3748">cy_wcm_ssid_t</a></div><div class="ttdeci">uint8_t cy_wcm_ssid_t[CY_WCM_MAX_SSID_LEN+1]</div><div class="ttdoc">SSID name (AP name in null-terminated string format).</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:396</div></div>
<div class="ttc" id="astructcy__wcm__scan__filter__t_html"><div class="ttname"><a href="structcy__wcm__scan__filter__t.html">cy_wcm_scan_filter_t</a></div><div class="ttdoc">Structure used to pass scan filters to cy_wcm_start_scan.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:494</div></div>
<div class="ttc" id="astructcy__wcm__scan__filter__t_html_a019063e2d7ac38f8123fa6181afc45b8"><div class="ttname"><a href="structcy__wcm__scan__filter__t.html#a019063e2d7ac38f8123fa6181afc45b8">cy_wcm_scan_filter_t::mode</a></div><div class="ttdeci">cy_wcm_scan_filter_type_t mode</div><div class="ttdoc">Scan filter mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:495</div></div>
<div class="ttc" id="astructcy__wcm__scan__filter__t_html_aa5503177afe2830f94a4e09ac6e675f3"><div class="ttname"><a href="structcy__wcm__scan__filter__t.html#aa5503177afe2830f94a4e09ac6e675f3">cy_wcm_scan_filter_t::param</a></div><div class="ttdeci">union cy_wcm_scan_filter_t::@1 param</div><div class="ttdoc">Parameter specific to scan filter mode.</div></div>
<div class="ttc" id="astructcy__wcm__scan__filter__t_html_ad8d3cb78527ac618f0a3994ac497cc35"><div class="ttname"><a href="structcy__wcm__scan__filter__t.html#ad8d3cb78527ac618f0a3994ac497cc35">cy_wcm_scan_filter_t::SSID</a></div><div class="ttdeci">cy_wcm_ssid_t SSID</div><div class="ttdoc">SSID.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:498</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip3"></a>
Snippet 3: Connect to an AP</h2>
<p >The following snippet demonstrates scanning for WIFI_SSID to get the security type of the AP and then connect to it. After a successful connection, the device registers an event callback through which the middleware notifies the application on disconnection, reconnection, and IP change events. If the connection to AP fails, it is retried up to MAX_WIFI_RETRY_COUNT times before reporting failure.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/* Wi-Fi Credentials: Modify WIFI_SSID and WIFI_PASSWORD to match your Wi-Fi network</span></div>
<div class="line"><span class="comment"> * credentials.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="preprocessor">#define WIFI_SSID                           &quot;SSID&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_PASSWORD                       &quot;PASSWORD&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#define MAX_WIFI_RETRY_COUNT                (3u)</span></div>
<div class="line"><span class="preprocessor">#define WIFI_CONN_RETRY_INTERVAL_MSEC       (100u)</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The size of the cy_wcm_ip_address_t array that is passed to</span></div>
<div class="line"><span class="comment"> * cy_wcm_get_ip_addr API. In the case of stand-alone AP or STA mode, the size of</span></div>
<div class="line"><span class="comment"> * the array is 1. In concurrent AP/STA mode, the size of the array is 2 where</span></div>
<div class="line"><span class="comment"> * the first index stores the IP address of the STA and the second index</span></div>
<div class="line"><span class="comment"> * stores the IP address of the AP.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Scan callback function */</span></div>
<div class="line"><span class="keywordtype">void</span> scan_to_get_security(<a class="code hl_struct" href="structcy__wcm__scan__result__t.html">cy_wcm_scan_result_t</a> *result_ptr, <span class="keywordtype">void</span> *user_data, <a class="code hl_enumeration" href="group__group__wcm__enums.html#ga24a4ed65a9261c45abc8aa697eb2b8a2">cy_wcm_scan_status_t</a> status)</div>
<div class="line">{</div>
<div class="line">    <a class="code hl_enumeration" href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a>* security = (<a class="code hl_enumeration" href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a> *)user_data;</div>
<div class="line">    <span class="comment">/* Scan for SSID and pass the security type through user_data.*/</span></div>
<div class="line">    <span class="keywordflow">if</span> ((strlen((<span class="keyword">const</span> <span class="keywordtype">char</span> *)result_ptr-&gt;<a class="code hl_variable" href="structcy__wcm__scan__result__t.html#adcf0e592c5ea946e9ce821b6a13262d4">SSID</a>) != 0) &amp;&amp; (status == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24a4ed65a9261c45abc8aa697eb2b8a2a01103577816da05a7b2b9521576c3c6e">CY_WCM_SCAN_INCOMPLETE</a>))</div>
<div class="line">    {</div>
<div class="line">        *security = result_ptr-&gt;<a class="code hl_variable" href="structcy__wcm__scan__result__t.html#a0bdbcaaaab6950223ad759eb1315daf2">security</a>;</div>
<div class="line">        <a class="code hl_function" href="group__group__wcm__functions.html#ga6c18f6560c581912393e297b1560d3c7">cy_wcm_stop_scan</a>();</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> network_event_callback(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Disconnected from Wi-Fi\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Reconnected to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">/* This event corresponds to the event when the IP address of the device</span></div>
<div class="line"><span class="comment">     * changes.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">        <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %d.%d.%d.%d\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>,</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 8), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 16),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 24));</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fcaa76a9ec3e0ee840982c8094f4416f768">CY_WCM_IP_VER_V6</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %X:%X:%X:%X\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0],</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1]), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2]),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3]));</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_connect_ap()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a> connect_param;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_address;</div>
<div class="line">    <a class="code hl_enumeration" href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a> security;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__scan__filter__t.html">cy_wcm_scan_filter_t</a> scan_filter;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Configure the scan filter specified by the macro WIFI_SSID.*/</span></div>
<div class="line">    scan_filter.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#a019063e2d7ac38f8123fa6181afc45b8">mode</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga568b22d5d446e751f62efe4eb021d451ae6a7c2fd74a727b9d1f3e0261533a7c4">CY_WCM_SCAN_FILTER_TYPE_SSID</a>;</div>
<div class="line">    memcpy(scan_filter.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#aa5503177afe2830f94a4e09ac6e675f3">param</a>.<a class="code hl_variable" href="structcy__wcm__scan__filter__t.html#ad8d3cb78527ac618f0a3994ac497cc35">SSID</a>, WIFI_SSID, <span class="keyword">sizeof</span>(WIFI_SSID));</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Scan with the filter to obtain the security type. The function waits</span></div>
<div class="line"><span class="comment">     * until the security type is obtained in scan_to_get_security.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#gae0f0b5f3e6138bfdae943e9f7b16aa07">cy_wcm_start_scan</a>(scan_to_get_security, (<span class="keywordtype">void</span> *)(&amp;security), &amp;scan_filter);</div>
<div class="line">    cy_rtos_delay_milliseconds(10000);</div>
<div class="line"> </div>
<div class="line">    memset(&amp;connect_param, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a>));</div>
<div class="line">    memset(&amp;ip_address, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a>));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID, <span class="keyword">sizeof</span>(WIFI_SSID));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_PASSWORD, <span class="keyword">sizeof</span>(WIFI_PASSWORD));</div>
<div class="line">    connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = security;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Attempt to connect to Wi-Fi until a connection is made or </span></div>
<div class="line"><span class="comment">     * MAX_WIFI_RETRY_COUNT attempts have been made.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">for</span> (uint32_t conn_retries = 0; conn_retries &lt; MAX_WIFI_RETRY_COUNT; conn_retries++)</div>
<div class="line">    {</div>
<div class="line">        result = <a class="code hl_function" href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a>(&amp;connect_param, &amp;ip_address);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (result == CY_RSLT_SUCCESS)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Successfully connected to Wi-Fi network &#39;%s&#39;.\n&quot;</span>, connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>);</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Register event callbacks for changes in the Wi-Fi link status. These</span></div>
<div class="line"><span class="comment">             * events could be related to IP address changes, connection, and</span></div>
<div class="line"><span class="comment">             * disconnection events.</span></div>
<div class="line"><span class="comment">             */</span></div>
<div class="line">            <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(network_event_callback);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        printf(<span class="stringliteral">&quot;Connection to Wi-Fi network failed with error code %d.&quot;</span></div>
<div class="line">                <span class="stringliteral">&quot;Retrying in %d ms...\n&quot;</span>, (<span class="keywordtype">int</span>)result, WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line"> </div>
<div class="line">        cy_rtos_delay_milliseconds(WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="ttc" id="agroup__group__wcm__enums_html_ga8b22f5a47073d5219440566d0e53e521"><div class="ttname"><a href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a></div><div class="ttdeci">cy_wcm_security_t</div><div class="ttdoc">Enumeration of Wi-Fi Security Modes.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:152</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gafada6a09a78bd0473f3daef54621567f"><div class="ttname"><a href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a></div><div class="ttdeci">cy_wcm_event_t</div><div class="ttdoc">Enumeration of WCM events.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:337</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a"><div class="ttname"><a href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a></div><div class="ttdeci">@ CY_WCM_IP_VER_V4</div><div class="ttdoc">Denotes IPv4 version.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:135</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga24d3def17207a3c64b62fb4b8a44a7fcaa76a9ec3e0ee840982c8094f4416f768"><div class="ttname"><a href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fcaa76a9ec3e0ee840982c8094f4416f768">CY_WCM_IP_VER_V6</a></div><div class="ttdeci">@ CY_WCM_IP_VER_V6</div><div class="ttdoc">Denotes IPv6 version.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:136</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a></div><div class="ttdeci">@ CY_WCM_EVENT_DISCONNECTED</div><div class="ttdoc">STA disconnected from the AP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:342</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a></div><div class="ttdeci">@ CY_WCM_EVENT_RECONNECTED</div><div class="ttdoc">STA reconnected to the AP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:341</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a></div><div class="ttdeci">@ CY_WCM_EVENT_IP_CHANGED</div><div class="ttdoc">IP address change event.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:343</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga02f205b4d522c99d6c0b48f15683b0b6"><div class="ttname"><a href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a></div><div class="ttdeci">cy_rslt_t cy_wcm_register_event_callback(cy_wcm_event_callback_t event_callback)</div><div class="ttdoc">Registers an event callback to monitor the connection and IP address change events.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga0aae35b5ae477a1a10caccf937beff0d"><div class="ttname"><a href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a></div><div class="ttdeci">cy_rslt_t cy_wcm_connect_ap(cy_wcm_connect_params_t *connect_params, cy_wcm_ip_address_t *ip_addr)</div><div class="ttdoc">Connects the STA interface to a AP using the Wi-Fi credentials and configuration parameters provided.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga6c18f6560c581912393e297b1560d3c7"><div class="ttname"><a href="group__group__wcm__functions.html#ga6c18f6560c581912393e297b1560d3c7">cy_wcm_stop_scan</a></div><div class="ttdeci">cy_rslt_t cy_wcm_stop_scan(void)</div><div class="ttdoc">Stops an ongoing Wi-Fi network scan.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_gad15fb09ca84b85997b967c3a22f9676c"><div class="ttname"><a href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a></div><div class="ttdeci">cy_rslt_t cy_wcm_get_ip_addr(cy_wcm_interface_t interface_type, cy_wcm_ip_address_t *ip_addr)</div><div class="ttdoc">Retrieves the IPv4 address of the given interface.</div></div>
<div class="ttc" id="astructcy__wcm__ap__credentials__t_html_a576fbc5a934d7efe6c98e265678c38d9"><div class="ttname"><a href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">cy_wcm_ap_credentials_t::security</a></div><div class="ttdeci">cy_wcm_security_t security</div><div class="ttdoc">Wi-Fi Security.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:463</div></div>
<div class="ttc" id="astructcy__wcm__ap__credentials__t_html_ad9ba797a8bc9bcb7708eb9b4560e3095"><div class="ttname"><a href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">cy_wcm_ap_credentials_t::password</a></div><div class="ttdeci">cy_wcm_passphrase_t password</div><div class="ttdoc">Password needed to join the AP; should be a null-terminated string.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:462</div></div>
<div class="ttc" id="astructcy__wcm__ap__credentials__t_html_aefb4693ca1fa808349032561a2e4b3bc"><div class="ttname"><a href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">cy_wcm_ap_credentials_t::SSID</a></div><div class="ttdeci">cy_wcm_ssid_t SSID</div><div class="ttdoc">SSID of the Wi-Fi network to join; should be a null-terminated string.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:461</div></div>
<div class="ttc" id="astructcy__wcm__connect__params__t_html"><div class="ttname"><a href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a></div><div class="ttdoc">Structure used to pass the Wi-Fi connection parameter information to cy_wcm_connect_ap.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:482</div></div>
<div class="ttc" id="astructcy__wcm__connect__params__t_html_add927d1d5bbaf348296daad9a6312023"><div class="ttname"><a href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">cy_wcm_connect_params_t::ap_credentials</a></div><div class="ttdeci">cy_wcm_ap_credentials_t ap_credentials</div><div class="ttdoc">AP credentials.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:483</div></div>
<div class="ttc" id="astructcy__wcm__ip__address__t_html"><div class="ttname"><a href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a></div><div class="ttdoc">Structure used to receive the IP address information from cy_wcm_connect_ap.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:436</div></div>
<div class="ttc" id="astructcy__wcm__ip__address__t_html_a7c275791b147e4ccd77ad178dd25bf81"><div class="ttname"><a href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">cy_wcm_ip_address_t::version</a></div><div class="ttdeci">cy_wcm_ip_version_t version</div><div class="ttdoc">IP version.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:437</div></div>
<div class="ttc" id="astructcy__wcm__ip__address__t_html_a86c6e6f9182502683675c0656a3ad088"><div class="ttname"><a href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">cy_wcm_ip_address_t::ip</a></div><div class="ttdeci">union cy_wcm_ip_address_t::@0 ip</div><div class="ttdoc">IP address bytes.</div></div>
<div class="ttc" id="astructcy__wcm__ip__address__t_html_a969244fd2e8b1da5fc07b75c4811e33c"><div class="ttname"><a href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">cy_wcm_ip_address_t::v6</a></div><div class="ttdeci">uint32_t v6[4]</div><div class="ttdoc">IPv6 address in network byte order.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:441</div></div>
<div class="ttc" id="astructcy__wcm__ip__address__t_html_acabea09ec2785e76f7d867a74dd6afd7"><div class="ttname"><a href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">cy_wcm_ip_address_t::v4</a></div><div class="ttdeci">uint32_t v4</div><div class="ttdoc">IPv4 address in network byte order.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:440</div></div>
<div class="ttc" id="astructcy__wcm__scan__result__t_html_a0bdbcaaaab6950223ad759eb1315daf2"><div class="ttname"><a href="structcy__wcm__scan__result__t.html#a0bdbcaaaab6950223ad759eb1315daf2">cy_wcm_scan_result_t::security</a></div><div class="ttdeci">cy_wcm_security_t security</div><div class="ttdoc">Security type.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:516</div></div>
<div class="ttc" id="aunioncy__wcm__event__data__t_html"><div class="ttname"><a href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a></div><div class="ttdoc">Structure used to receive the IP address of the STA or MAC address of the connected STA to SoftAP thr...</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:449</div></div>
<div class="ttc" id="aunioncy__wcm__event__data__t_html_a9c8f9a98e351394d704d1796328ae466"><div class="ttname"><a href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">cy_wcm_event_data_t::ip_addr</a></div><div class="ttdeci">cy_wcm_ip_address_t ip_addr</div><div class="ttdoc">Contains the IP address for the CY_WCM_EVENT_IP_CHANGED event.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:450</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip4"></a>
Snippet 4: Connect to an AP using the WPS-Push button</h2>
<p >The following snippet demonstrates joining an AP and obtaining its credentials through WPS using the push button mode. The credentials obtained are printed on the serial terminal.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/* The value of this macro specifies the maximum number of Wi-Fi networks the</span></div>
<div class="line"><span class="comment"> * device can join through WPS in one call to cy_wcm_wps_enrollee. This value is</span></div>
<div class="line"><span class="comment"> * 2 for dual-band AP. Note that the device can obtain Wi-Fi credentials of only</span></div>
<div class="line"><span class="comment"> * one network and therefore can receive a maximum of 1 for single-band Wi-Fi AP or</span></div>
<div class="line"><span class="comment"> * 2 for dual-band AP.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="preprocessor">#define MAX_WIFI_CREDENTIALS_COUNT          (2)</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Device&#39;s enrollee details. Details of WPS mode, WPS authentication, and</span></div>
<div class="line"><span class="comment"> * encryption methods supported are provided in this structure.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keyword">const</span> <a class="code hl_struct" href="structcy__wcm__wps__device__detail__t.html">cy_wcm_wps_device_detail_t</a> enrollee_details =</div>
<div class="line">{</div>
<div class="line">    .<a class="code hl_variable" href="structcy__wcm__wps__device__detail__t.html#af691ce3681ce5c0307f43576271b61b8">device_name</a>               = <span class="stringliteral">&quot;PSoC 6&quot;</span>,</div>
<div class="line">    .manufacturer              = <span class="stringliteral">&quot;Cypress&quot;</span>,</div>
<div class="line">    .model_name                = <span class="stringliteral">&quot;PSoC 6&quot;</span>,</div>
<div class="line">    .model_number              = <span class="stringliteral">&quot;1.0&quot;</span>,</div>
<div class="line">    .serial_number             = <span class="stringliteral">&quot;1234567&quot;</span>,</div>
<div class="line">    .device_category           = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga2109f4415e7d9d586336f8c4415a270ea38c2c17db9981b8d58c56a03d9eea174">CY_WCM_WPS_DEVICE_COMPUTER</a>,</div>
<div class="line">    .sub_category              = 7,</div>
<div class="line">    .config_methods            = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1ace529442cbd31b83e4ac5a4b3ed33e0a">CY_WCM_WPS_CONFIG_LABEL</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1aaa30b78f42df81269f3c1b4e2cb8b563">CY_WCM_WPS_CONFIG_VIRTUAL_PUSH_BUTTON</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1aadb10bf953fe76e72cbf4dcddfbc38df">CY_WCM_WPS_CONFIG_VIRTUAL_DISPLAY_PIN</a>,</div>
<div class="line">    .authentication_type_flags = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a9936e971dccb38e7cf02448690e11359">CY_WCM_WPS_OPEN_AUTHENTICATION</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a97ad9d0d773ae0615f119a19c92b902e">CY_WCM_WPS_WPA_PSK_AUTHENTICATION</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a56f28a09b4389cd4b9a16e8d443c962a">CY_WCM_WPS_WPA2_PSK_AUTHENTICATION</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a89ef5b1e77a439a54f7fae94a2b0dd87">CY_WCM_WPS_WPA2_WPA_PSK_MIXED_AUTHENTICATION</a>,</div>
<div class="line">    .encryption_type_flags     = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fadecaa9e74027491e62c637b65f7f6cbd">CY_WCM_WPS_NO_ENCRYPTION</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fa03e109443caa4e7956944d22e3a00c36">CY_WCM_WPS_AES_ENCRYPTION</a> | <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fa8a6bf58d9350921fec4e196d35803a7d">CY_WCM_WPS_TKIP_ENCRYPTION</a></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_wps_pbc()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Store the credentials obtained through WPS.*/</span></div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__wps__credential__t.html">cy_wcm_wps_credential_t</a> credentials[MAX_WIFI_CREDENTIALS_COUNT];</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__wps__config__t.html">cy_wcm_wps_config_t</a> wps_config;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Store the PIN used for WPS. It is unused when PBC mode is employed.*/</span></div>
<div class="line">    <span class="keywordtype">char</span> pin_string[<a class="code hl_define" href="group__group__wcm__macros.html#ga2fd33d6cf6472c7452a22e5988e69516">CY_WCM_WPS_PIN_LENGTH</a>];</div>
<div class="line">    uint16_t credential_count = MAX_WIFI_CREDENTIALS_COUNT;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/*Configure the mode of the WPS as CY_WCM_WPS_PBC_MODE.*/</span></div>
<div class="line">    wps_config.<a class="code hl_variable" href="structcy__wcm__wps__config__t.html#ad45eecaffb10e893f240bf42c05c453b">mode</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga522893594393679bacaaaa77d81b26f8a31835b09070e6bd6c1728168e549c09c">CY_WCM_WPS_PBC_MODE</a>;</div>
<div class="line">    wps_config.<a class="code hl_variable" href="structcy__wcm__wps__config__t.html#ac9878359549a01538c7a9bcda83abde7">password</a> = pin_string;</div>
<div class="line">    memset(credentials, 0, <span class="keyword">sizeof</span>(credentials));</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;Press the push button on your WPS AP.\n&quot;</span>);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga97e7212b4d3392a310682ff02f0d8d51">cy_wcm_wps_enrollee</a>(&amp;wps_config, &amp;enrollee_details, credentials, &amp;credential_count);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (CY_RSLT_SUCCESS == result)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;WPS Success.\n&quot;</span>);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">/* Print the WPS credentials obtained through WPS.*/</span></div>
<div class="line">        <span class="keywordflow">for</span> (uint32_t loop = 0; loop &lt; credential_count; loop++)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;%d. SSID = %s, Password = %c%c******.\n&quot;</span>, (uint8_t)loop + 1, credentials[loop].ssid, credentials[loop].passphrase[0], credentials[loop].passphrase[1]);</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga2109f4415e7d9d586336f8c4415a270ea38c2c17db9981b8d58c56a03d9eea174"><div class="ttname"><a href="group__group__wcm__enums.html#gga2109f4415e7d9d586336f8c4415a270ea38c2c17db9981b8d58c56a03d9eea174">CY_WCM_WPS_DEVICE_COMPUTER</a></div><div class="ttdeci">@ CY_WCM_WPS_DEVICE_COMPUTER</div><div class="ttdoc">Computer devices.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:318</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga522893594393679bacaaaa77d81b26f8a31835b09070e6bd6c1728168e549c09c"><div class="ttname"><a href="group__group__wcm__enums.html#gga522893594393679bacaaaa77d81b26f8a31835b09070e6bd6c1728168e549c09c">CY_WCM_WPS_PBC_MODE</a></div><div class="ttdeci">@ CY_WCM_WPS_PBC_MODE</div><div class="ttdoc">Push button mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:261</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga7ef358e8ada90c5a7d7a170d9c87f06fa03e109443caa4e7956944d22e3a00c36"><div class="ttname"><a href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fa03e109443caa4e7956944d22e3a00c36">CY_WCM_WPS_AES_ENCRYPTION</a></div><div class="ttdeci">@ CY_WCM_WPS_AES_ENCRYPTION</div><div class="ttdoc">AES encryption.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:306</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga7ef358e8ada90c5a7d7a170d9c87f06fa8a6bf58d9350921fec4e196d35803a7d"><div class="ttname"><a href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fa8a6bf58d9350921fec4e196d35803a7d">CY_WCM_WPS_TKIP_ENCRYPTION</a></div><div class="ttdeci">@ CY_WCM_WPS_TKIP_ENCRYPTION</div><div class="ttdoc">TKIP encryption - Deprecated in WSC 2.0.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:307</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga7ef358e8ada90c5a7d7a170d9c87f06fadecaa9e74027491e62c637b65f7f6cbd"><div class="ttname"><a href="group__group__wcm__enums.html#gga7ef358e8ada90c5a7d7a170d9c87f06fadecaa9e74027491e62c637b65f7f6cbd">CY_WCM_WPS_NO_ENCRYPTION</a></div><div class="ttdeci">@ CY_WCM_WPS_NO_ENCRYPTION</div><div class="ttdoc">OPEN - No encryption.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:309</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggab50f2a67cec69a058057fc5fc6c5cea1a56f28a09b4389cd4b9a16e8d443c962a"><div class="ttname"><a href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a56f28a09b4389cd4b9a16e8d443c962a">CY_WCM_WPS_WPA2_PSK_AUTHENTICATION</a></div><div class="ttdeci">@ CY_WCM_WPS_WPA2_PSK_AUTHENTICATION</div><div class="ttdoc">WPA2-PSK authentication type.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:296</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggab50f2a67cec69a058057fc5fc6c5cea1a89ef5b1e77a439a54f7fae94a2b0dd87"><div class="ttname"><a href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a89ef5b1e77a439a54f7fae94a2b0dd87">CY_WCM_WPS_WPA2_WPA_PSK_MIXED_AUTHENTICATION</a></div><div class="ttdeci">@ CY_WCM_WPS_WPA2_WPA_PSK_MIXED_AUTHENTICATION</div><div class="ttdoc">WPA2-WPA-PSK authentication type.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:297</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggab50f2a67cec69a058057fc5fc6c5cea1a97ad9d0d773ae0615f119a19c92b902e"><div class="ttname"><a href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a97ad9d0d773ae0615f119a19c92b902e">CY_WCM_WPS_WPA_PSK_AUTHENTICATION</a></div><div class="ttdeci">@ CY_WCM_WPS_WPA_PSK_AUTHENTICATION</div><div class="ttdoc">WPA-PSK authentication type - Deprecated in version 2.0.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:292</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggab50f2a67cec69a058057fc5fc6c5cea1a9936e971dccb38e7cf02448690e11359"><div class="ttname"><a href="group__group__wcm__enums.html#ggab50f2a67cec69a058057fc5fc6c5cea1a9936e971dccb38e7cf02448690e11359">CY_WCM_WPS_OPEN_AUTHENTICATION</a></div><div class="ttdeci">@ CY_WCM_WPS_OPEN_AUTHENTICATION</div><div class="ttdoc">Authentication type OPEN.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:291</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafef6a7e734e688418bfa6c601edf2cf1aaa30b78f42df81269f3c1b4e2cb8b563"><div class="ttname"><a href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1aaa30b78f42df81269f3c1b4e2cb8b563">CY_WCM_WPS_CONFIG_VIRTUAL_PUSH_BUTTON</a></div><div class="ttdeci">@ CY_WCM_WPS_CONFIG_VIRTUAL_PUSH_BUTTON</div><div class="ttdoc">Virtual push button configuration.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:279</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafef6a7e734e688418bfa6c601edf2cf1aadb10bf953fe76e72cbf4dcddfbc38df"><div class="ttname"><a href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1aadb10bf953fe76e72cbf4dcddfbc38df">CY_WCM_WPS_CONFIG_VIRTUAL_DISPLAY_PIN</a></div><div class="ttdeci">@ CY_WCM_WPS_CONFIG_VIRTUAL_DISPLAY_PIN</div><div class="ttdoc">Virtual display pin configuration.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:281</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafef6a7e734e688418bfa6c601edf2cf1ace529442cbd31b83e4ac5a4b3ed33e0a"><div class="ttname"><a href="group__group__wcm__enums.html#ggafef6a7e734e688418bfa6c601edf2cf1ace529442cbd31b83e4ac5a4b3ed33e0a">CY_WCM_WPS_CONFIG_LABEL</a></div><div class="ttdeci">@ CY_WCM_WPS_CONFIG_LABEL</div><div class="ttdoc">Label configuration.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:272</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga97e7212b4d3392a310682ff02f0d8d51"><div class="ttname"><a href="group__group__wcm__functions.html#ga97e7212b4d3392a310682ff02f0d8d51">cy_wcm_wps_enrollee</a></div><div class="ttdeci">cy_rslt_t cy_wcm_wps_enrollee(cy_wcm_wps_config_t *config, const cy_wcm_wps_device_detail_t *details, cy_wcm_wps_credential_t *credentials, uint16_t *credential_count)</div><div class="ttdoc">Negotiates securely with a Wi-Fi Protected Setup (WPS) Registrar (usually an AP) and obtains the Wi-F...</div></div>
<div class="ttc" id="agroup__group__wcm__macros_html_ga2fd33d6cf6472c7452a22e5988e69516"><div class="ttname"><a href="group__group__wcm__macros.html#ga2fd33d6cf6472c7452a22e5988e69516">CY_WCM_WPS_PIN_LENGTH</a></div><div class="ttdeci">#define CY_WCM_WPS_PIN_LENGTH</div><div class="ttdoc">WPS password length for PIN mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:114</div></div>
<div class="ttc" id="astructcy__wcm__wps__config__t_html"><div class="ttname"><a href="structcy__wcm__wps__config__t.html">cy_wcm_wps_config_t</a></div><div class="ttdoc">Structure used to pass WPS configuration parameters to cy_wcm_wps_enrollee.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:418</div></div>
<div class="ttc" id="astructcy__wcm__wps__config__t_html_ac9878359549a01538c7a9bcda83abde7"><div class="ttname"><a href="structcy__wcm__wps__config__t.html#ac9878359549a01538c7a9bcda83abde7">cy_wcm_wps_config_t::password</a></div><div class="ttdeci">char * password</div><div class="ttdoc">Used only for CY_WCM_WPS_PIN mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:420</div></div>
<div class="ttc" id="astructcy__wcm__wps__config__t_html_ad45eecaffb10e893f240bf42c05c453b"><div class="ttname"><a href="structcy__wcm__wps__config__t.html#ad45eecaffb10e893f240bf42c05c453b">cy_wcm_wps_config_t::mode</a></div><div class="ttdeci">cy_wcm_wps_mode_t mode</div><div class="ttdoc">WPS mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:419</div></div>
<div class="ttc" id="astructcy__wcm__wps__credential__t_html"><div class="ttname"><a href="structcy__wcm__wps__credential__t.html">cy_wcm_wps_credential_t</a></div><div class="ttdoc">Structure used to receive the AP credential after WPS is completed successfully from cy_wcm_wps_enrol...</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:549</div></div>
<div class="ttc" id="astructcy__wcm__wps__device__detail__t_html"><div class="ttname"><a href="structcy__wcm__wps__device__detail__t.html">cy_wcm_wps_device_detail_t</a></div><div class="ttdoc">Structure used to pass the device information to cy_wcm_wps_enrollee.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:530</div></div>
<div class="ttc" id="astructcy__wcm__wps__device__detail__t_html_af691ce3681ce5c0307f43576271b61b8"><div class="ttname"><a href="structcy__wcm__wps__device__detail__t.html#af691ce3681ce5c0307f43576271b61b8">cy_wcm_wps_device_detail_t::device_name</a></div><div class="ttdeci">const char * device_name</div><div class="ttdoc">Device name.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:533</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip5"></a>
Snippet 5: Connect to an AP using WPS-PIN</h2>
<p >The following snippet demonstrates joining an AP and obtaining its credentials through WPS using the PIN mode. The credentials obtained are printed on the serial terminal.</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> snippet_wcm_wps_pin()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__wps__credential__t.html">cy_wcm_wps_credential_t</a> credentials[MAX_WIFI_CREDENTIALS_COUNT];</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__wps__config__t.html">cy_wcm_wps_config_t</a> wps_config;</div>
<div class="line">    <span class="keywordtype">char</span> pin_string[<a class="code hl_define" href="group__group__wcm__macros.html#ga2fd33d6cf6472c7452a22e5988e69516">CY_WCM_WPS_PIN_LENGTH</a>];</div>
<div class="line">    uint16_t credential_count = MAX_WIFI_CREDENTIALS_COUNT;</div>
<div class="line"> </div>
<div class="line">    memset(credentials, 0, <span class="keyword">sizeof</span>(credentials));</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Here, the WPS PIN is generated by the device. The user must</span></div>
<div class="line"><span class="comment">     * enter the PIN in the AP to join the network through WPS.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#ga0369189fc2845efdf57cd3ce9b0d188e">cy_wcm_wps_generate_pin</a>(pin_string);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/*Configure the mode of WPS as CY_WCM_WPS_PIN_MODE.*/</span></div>
<div class="line">    wps_config.<a class="code hl_variable" href="structcy__wcm__wps__config__t.html#ad45eecaffb10e893f240bf42c05c453b">mode</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga522893594393679bacaaaa77d81b26f8a95b8f9041290279c8c309fa985241565">CY_WCM_WPS_PIN_MODE</a>;</div>
<div class="line">    wps_config.<a class="code hl_variable" href="structcy__wcm__wps__config__t.html#ac9878359549a01538c7a9bcda83abde7">password</a> = pin_string;</div>
<div class="line">    printf(<span class="stringliteral">&quot;Enter this PIN: \&#39;%s\&#39; in your AP.\n&quot;</span>, pin_string);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga97e7212b4d3392a310682ff02f0d8d51">cy_wcm_wps_enrollee</a>(&amp;wps_config, &amp;enrollee_details, credentials, &amp;credential_count);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (CY_RSLT_SUCCESS == result)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;WPS Success.\n&quot;</span>);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">/* Print the WPS credentials obtained through WPS.*/</span></div>
<div class="line">        <span class="keywordflow">for</span> (uint32_t loop = 0; loop &lt; credential_count; loop++)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;%d. SSID = %s, Password = %c%c******.\n&quot;</span>, (uint8_t)loop + 1, credentials[loop].ssid, credentials[loop].passphrase[0], credentials[loop].passphrase[1]);</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga522893594393679bacaaaa77d81b26f8a95b8f9041290279c8c309fa985241565"><div class="ttname"><a href="group__group__wcm__enums.html#gga522893594393679bacaaaa77d81b26f8a95b8f9041290279c8c309fa985241565">CY_WCM_WPS_PIN_MODE</a></div><div class="ttdeci">@ CY_WCM_WPS_PIN_MODE</div><div class="ttdoc">PIN mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:262</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga0369189fc2845efdf57cd3ce9b0d188e"><div class="ttname"><a href="group__group__wcm__functions.html#ga0369189fc2845efdf57cd3ce9b0d188e">cy_wcm_wps_generate_pin</a></div><div class="ttdeci">cy_rslt_t cy_wcm_wps_generate_pin(char wps_pin_string[CY_WCM_WPS_PIN_LENGTH])</div><div class="ttdoc">Generates a random WPS PIN for PIN mode connection.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip6"></a>
Snippet 6: Pinging the gateway IP address</h2>
<p >The following snippet demonstrates ping to the gateway IP address with a STA mode connection.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#define WIFI_SSID                           &quot;SSID&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_PASSWORD                       &quot;PASSWORD&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#define MAX_WIFI_RETRY_COUNT                (3u)</span></div>
<div class="line"><span class="preprocessor">#define WIFI_CONN_RETRY_INTERVAL_MSEC       (100u)</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_sta_ping()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device as a STA.*/</span></div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> config = {.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>};</div>
<div class="line"> </div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a> connect_param;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_address;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr, gateway_addr;</div>
<div class="line">    uint32_t elapsed_time_ms;</div>
<div class="line"> </div>
<div class="line">    memset(&amp;connect_param, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a>));</div>
<div class="line">    memset(&amp;ip_address, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a>));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID, <span class="keyword">sizeof</span>(WIFI_SSID));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_PASSWORD, <span class="keyword">sizeof</span>(WIFI_PASSWORD));</div>
<div class="line">    connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device, Wi-Fi transport, and lwIP network stack.*/</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;config);</div>
<div class="line">    <span class="keywordflow">if</span> (result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_init failed...!\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;\n*** Starting STA Mode ***\n&quot;</span>);</div>
<div class="line">    <span class="comment">/* Attempt to connect to Wi-Fi until a connection is made or</span></div>
<div class="line"><span class="comment">     * MAX_WIFI_RETRY_COUNT attempts have been made.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">for</span> (uint32_t conn_retries = 0; conn_retries &lt; MAX_WIFI_RETRY_COUNT; conn_retries++)</div>
<div class="line">    {</div>
<div class="line">        result = <a class="code hl_function" href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a>(&amp;connect_param, &amp;ip_address);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (result == CY_RSLT_SUCCESS)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Successfully connected to Wi-Fi network &#39;%s&#39;.\n&quot;</span>, connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        printf(<span class="stringliteral">&quot;Connection to Wi-Fi network failed with error code %d.&quot;</span></div>
<div class="line">                <span class="stringliteral">&quot;Retrying in %d ms...\n&quot;</span>, (<span class="keywordtype">int</span>)result, WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line"> </div>
<div class="line">        cy_rtos_delay_milliseconds(WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get IPv4 address */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line">    nw_ipv4.ip.v4 = ip_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get gateway address */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#ga4cb1814cad97c2462b27aec17294acfb">cy_wcm_get_gateway_ip_address</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;gateway_addr);</div>
<div class="line">    nw_ipv4.ip.v4 = gateway_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line"> </div>
<div class="line">    cy_rtos_delay_milliseconds(2000);</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;Pinging to gateway IP address ... \n&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Send PING request with 3000ms ping timeout */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gaa42251a4b728f775786d1781afbc32a2">cy_wcm_ping</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;gateway_addr, 3000, &amp;elapsed_time_ms);</div>
<div class="line">    <span class="keywordflow">if</span>( result == CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;ping was successful time elapsed = %u\n&quot;</span>, (uint8_t)elapsed_time_ms);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span></div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Ping failed !!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe"><div class="ttname"><a href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a></div><div class="ttdeci">@ CY_WCM_SECURITY_WPA2_AES_PSK</div><div class="ttdoc">WPA2 PSK security with AES.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:159</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga4cb1814cad97c2462b27aec17294acfb"><div class="ttname"><a href="group__group__wcm__functions.html#ga4cb1814cad97c2462b27aec17294acfb">cy_wcm_get_gateway_ip_address</a></div><div class="ttdeci">cy_rslt_t cy_wcm_get_gateway_ip_address(cy_wcm_interface_t interface_type, cy_wcm_ip_address_t *gateway_addr)</div><div class="ttdoc">Retrieves the gateway IP address of the given interface.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_gaa42251a4b728f775786d1781afbc32a2"><div class="ttname"><a href="group__group__wcm__functions.html#gaa42251a4b728f775786d1781afbc32a2">cy_wcm_ping</a></div><div class="ttdeci">cy_rslt_t cy_wcm_ping(cy_wcm_interface_t interface, cy_wcm_ip_address_t *ip_addr, uint32_t timeout_ms, uint32_t *elapsed_ms)</div><div class="ttdoc">Sends a ping request to the given IP address.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip7"></a>
Snippet 7: SoftAP start-stop</h2>
<p >The following snippet demonstrates SoftAP start and stop.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#define WIFI_SSID_AP                      &quot;AnyCloud&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_KEY_AP                       &quot;abcd@9009&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="structcy__wcm__ip__setting__t.html">cy_wcm_ip_setting_t</a> ap_mode_ip_settings;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> ap_event_cb(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    </div>
<div class="line">    printf(<span class="stringliteral">&quot;######### Received event changed from wcm, event = %d #######\n&quot;</span>, event);</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is down! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is up again! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852">CY_WCM_EVENT_CONNECTING</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connecting to AP ... \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f">CY_WCM_EVENT_CONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connected to AP and network is up !! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5">CY_WCM_EVENT_CONNECT_FAILED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connection to AP Failed ! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a>:</div>
<div class="line">        {</div>
<div class="line">            <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">            <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">            {</div>
<div class="line">                nw_ipv4.ip.v4 = event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">                cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">                printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa89bf3f175e03aabb5951138e229392c9">CY_WCM_EVENT_STA_JOINED_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which joined = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa54168b9c07156a695d1de5db77f03bcb">CY_WCM_EVENT_STA_LEFT_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which left = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Invalid event \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }        </div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_ap_start_stop()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <span class="keywordtype">char</span> ip6_str[40];</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    <span class="keywordtype">char</span> *ip = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *netmask = <span class="stringliteral">&quot;255.255.255.0&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *gateway = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv6;</div>
<div class="line">    </div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a> ap_conf;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ipv6_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device, Wi-Fi transport, and lwIP network stack.*/</span></div>
<div class="line">    config.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;config);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_init failed...!\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* AP settings */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#gadfcd3cdd92c62bcfd7b0ee53c7e4da7b">cy_wcm_set_ap_ip_setting</a>(&amp;ap_mode_ip_settings, ip, netmask, gateway, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>);</div>
<div class="line">    </div>
<div class="line">    memset(&amp;ap_conf, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a>));</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a43adeebc56159fdac2d1e0a19334fb6f">channel</a> = 1;</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID_AP, strlen(WIFI_SSID_AP) + 1);</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_KEY_AP, strlen(WIFI_KEY_AP) + 1);</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a> = ap_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a> = ap_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a> = ap_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a>;</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;configured ip address of the AP = %u \n&quot;</span>, (uint8_t)ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>);</div>
<div class="line">    nw_ipv4.ip.v4 = ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Start AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga4b6c66ca0e28ef817bdab02c56d180e6">cy_wcm_start_ap</a>(&amp;ap_conf);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_start_ap failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Register AP event callback */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(&amp;ap_event_cb);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_register_event_callback failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Link Local IPV6 AP address for AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga88dbfc2742725a2c54223740cb27b518">cy_wcm_get_ipv6_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac">CY_WCM_IPV6_LINK_LOCAL</a>, &amp;ipv6_addr);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_ipv6_addr failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    nw_ipv6.ip.v6[0] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0];</div>
<div class="line">    nw_ipv6.ip.v6[1] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1];</div>
<div class="line">    nw_ipv6.ip.v6[2] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2];</div>
<div class="line">    nw_ipv6.ip.v6[3] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3];</div>
<div class="line">    cy_nw_ntoa_ipv6(&amp;nw_ipv6, ip6_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV6 address: %s\n&quot;</span>, ip6_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* wait for 30 seconds to check whether AP is visible or not */</span></div>
<div class="line">    cy_rtos_delay_milliseconds(30000);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Stop AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gaaf300adeaed2e9251dc85d6c85be9d72">cy_wcm_stop_ap</a>();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_stop_ap failed....! \n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">return</span>;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__enums_html_gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac"><div class="ttname"><a href="group__group__wcm__enums.html#gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac">CY_WCM_IPV6_LINK_LOCAL</a></div><div class="ttdeci">@ CY_WCM_IPV6_LINK_LOCAL</div><div class="ttdoc">Denotes IPv6 link-local address type.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:144</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f"><div class="ttname"><a href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a></div><div class="ttdeci">@ CY_WCM_INTERFACE_TYPE_AP</div><div class="ttdoc">SoftAP interface.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:233</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f">CY_WCM_EVENT_CONNECTED</a></div><div class="ttdeci">@ CY_WCM_EVENT_CONNECTED</div><div class="ttdoc">STA connected to the AP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:339</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fa54168b9c07156a695d1de5db77f03bcb"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa54168b9c07156a695d1de5db77f03bcb">CY_WCM_EVENT_STA_LEFT_SOFTAP</a></div><div class="ttdeci">@ CY_WCM_EVENT_STA_LEFT_SOFTAP</div><div class="ttdoc">An STA device disconnected from SoftAP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:346</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852">CY_WCM_EVENT_CONNECTING</a></div><div class="ttdeci">@ CY_WCM_EVENT_CONNECTING</div><div class="ttdoc">STA connecting to an AP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:338</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fa89bf3f175e03aabb5951138e229392c9"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa89bf3f175e03aabb5951138e229392c9">CY_WCM_EVENT_STA_JOINED_SOFTAP</a></div><div class="ttdeci">@ CY_WCM_EVENT_STA_JOINED_SOFTAP</div><div class="ttdoc">An STA device connected to SoftAP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:345</div></div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5"><div class="ttname"><a href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5">CY_WCM_EVENT_CONNECT_FAILED</a></div><div class="ttdeci">@ CY_WCM_EVENT_CONNECT_FAILED</div><div class="ttdoc">STA connection to the AP failed.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:340</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga4b6c66ca0e28ef817bdab02c56d180e6"><div class="ttname"><a href="group__group__wcm__functions.html#ga4b6c66ca0e28ef817bdab02c56d180e6">cy_wcm_start_ap</a></div><div class="ttdeci">cy_rslt_t cy_wcm_start_ap(const cy_wcm_ap_config_t *ap_config)</div><div class="ttdoc">Starts an infrastructure Wi-Fi network (SoftAP).</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga88dbfc2742725a2c54223740cb27b518"><div class="ttname"><a href="group__group__wcm__functions.html#ga88dbfc2742725a2c54223740cb27b518">cy_wcm_get_ipv6_addr</a></div><div class="ttdeci">cy_rslt_t cy_wcm_get_ipv6_addr(cy_wcm_interface_t interface_type, cy_wcm_ipv6_type_t ipv6_addr_type, cy_wcm_ip_address_t *ip_addr)</div><div class="ttdoc">Retrieves the IPv6 address of the given interface.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_gaaf300adeaed2e9251dc85d6c85be9d72"><div class="ttname"><a href="group__group__wcm__functions.html#gaaf300adeaed2e9251dc85d6c85be9d72">cy_wcm_stop_ap</a></div><div class="ttdeci">cy_rslt_t cy_wcm_stop_ap(void)</div><div class="ttdoc">Stops the infrastructure Wi-Fi network (SoftAP), removes the information element and stops the intern...</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_gadfcd3cdd92c62bcfd7b0ee53c7e4da7b"><div class="ttname"><a href="group__group__wcm__functions.html#gadfcd3cdd92c62bcfd7b0ee53c7e4da7b">cy_wcm_set_ap_ip_setting</a></div><div class="ttdeci">cy_rslt_t cy_wcm_set_ap_ip_setting(cy_wcm_ip_setting_t *ap_ip, const char *ip_addr, const char *netmask, const char *gateway_addr, cy_wcm_ip_version_t ver)</div><div class="ttdoc">Stores the AP settings provided by the user.</div></div>
<div class="ttc" id="astructcy__wcm__ap__config__t_html"><div class="ttname"><a href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a></div><div class="ttdoc">Structure used to configure the access point.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:598</div></div>
<div class="ttc" id="astructcy__wcm__ap__config__t_html_a41b9a70a96b5567416a37661a84b3e7c"><div class="ttname"><a href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">cy_wcm_ap_config_t::ap_credentials</a></div><div class="ttdeci">cy_wcm_ap_credentials_t ap_credentials</div><div class="ttdoc">AP credentials.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:599</div></div>
<div class="ttc" id="astructcy__wcm__ap__config__t_html_a43adeebc56159fdac2d1e0a19334fb6f"><div class="ttname"><a href="structcy__wcm__ap__config__t.html#a43adeebc56159fdac2d1e0a19334fb6f">cy_wcm_ap_config_t::channel</a></div><div class="ttdeci">uint8_t channel</div><div class="ttdoc">Radio channel of the AP.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:601</div></div>
<div class="ttc" id="astructcy__wcm__ap__config__t_html_a4d26be457ca32e36d8162c3eb347491b"><div class="ttname"><a href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">cy_wcm_ap_config_t::ip_settings</a></div><div class="ttdeci">cy_wcm_ip_setting_t ip_settings</div><div class="ttdoc">IP settings of the AP interface.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:602</div></div>
<div class="ttc" id="astructcy__wcm__ip__setting__t_html"><div class="ttname"><a href="structcy__wcm__ip__setting__t.html">cy_wcm_ip_setting_t</a></div><div class="ttdoc">Structure used to pass the static IP address information to cy_wcm_connect_ap.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:471</div></div>
<div class="ttc" id="astructcy__wcm__ip__setting__t_html_a2e28eec7ae6e6301101991039b5b3bd0"><div class="ttname"><a href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">cy_wcm_ip_setting_t::gateway</a></div><div class="ttdeci">cy_wcm_ip_address_t gateway</div><div class="ttdoc">Gateway address.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:473</div></div>
<div class="ttc" id="astructcy__wcm__ip__setting__t_html_a56bf0370a561c858da2008255d0f12bc"><div class="ttname"><a href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">cy_wcm_ip_setting_t::netmask</a></div><div class="ttdeci">cy_wcm_ip_address_t netmask</div><div class="ttdoc">Netmask.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:474</div></div>
<div class="ttc" id="astructcy__wcm__ip__setting__t_html_aab6aea9cfd72daa55d92f86046e594dd"><div class="ttname"><a href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">cy_wcm_ip_setting_t::ip_address</a></div><div class="ttdeci">cy_wcm_ip_address_t ip_address</div><div class="ttdoc">IP address.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:472</div></div>
<div class="ttc" id="aunioncy__wcm__event__data__t_html_aa2f4d769a35b7859bf0649d29b5f46a4"><div class="ttname"><a href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">cy_wcm_event_data_t::sta_mac</a></div><div class="ttdeci">cy_wcm_mac_t sta_mac</div><div class="ttdoc">MAC address of the STA for the CY_WCM_EVENT_STA_JOINED or CY_WCM_EVENT_STA_LEFT.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:451</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip8"></a>
Snippet 8: Clients connected to the SoftAP</h2>
<p >The following snippet demonstrates usage of the <a class="el" href="group__group__wcm__functions.html#gac2570e24e41dc550252205489f56cc0f">cy_wcm_get_associated_client_list</a> API function to get the list of clients connected to the SoftAP.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="preprocessor">#define WIFI_SSID_AP                      &quot;AnyCloud&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_KEY_AP                       &quot;abcd@9009&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="structcy__wcm__ip__setting__t.html">cy_wcm_ip_setting_t</a> ap_ip_settings;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> ap_eve_callback(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    </div>
<div class="line">    printf(<span class="stringliteral">&quot;######### Received event changed from wcm, event = %d #######\n&quot;</span>, event);</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is down! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is up again! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852">CY_WCM_EVENT_CONNECTING</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connecting to AP ... \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f">CY_WCM_EVENT_CONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connected to AP and network is up !! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5">CY_WCM_EVENT_CONNECT_FAILED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connection to AP Failed ! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a>:</div>
<div class="line">        {</div>
<div class="line">            <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">            <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">            {</div>
<div class="line">                nw_ipv4.ip.v4 = event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">                cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">                printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa89bf3f175e03aabb5951138e229392c9">CY_WCM_EVENT_STA_JOINED_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which joined = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa54168b9c07156a695d1de5db77f03bcb">CY_WCM_EVENT_STA_LEFT_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which left = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Invalid event \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }        </div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_ap_get_client()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <span class="keywordtype">char</span> ip6_str[40];</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    <span class="keywordtype">char</span> *ip = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *netmask = <span class="stringliteral">&quot;255.255.255.0&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *gateway = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv6;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    </div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a> ap_conf;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ipv6_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device, Wi-Fi transport, and lwIP network stack.*/</span></div>
<div class="line">    config.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;config);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_init failed...!\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* AP settings */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#gadfcd3cdd92c62bcfd7b0ee53c7e4da7b">cy_wcm_set_ap_ip_setting</a>(&amp;ap_ip_settings, ip, netmask, gateway, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>);</div>
<div class="line">    </div>
<div class="line">    memset(&amp;ap_conf, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a>));</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a43adeebc56159fdac2d1e0a19334fb6f">channel</a> = 1;</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID_AP, strlen(WIFI_SSID_AP) + 1);</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_KEY_AP, strlen(WIFI_KEY_AP) + 1);</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a> = ap_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a> = ap_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a> = ap_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a>;</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;configured ip address of the AP = %u \n&quot;</span>, (uint8_t)ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>);</div>
<div class="line">    nw_ipv4.ip.v4 = ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Start AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga4b6c66ca0e28ef817bdab02c56d180e6">cy_wcm_start_ap</a>(&amp;ap_conf);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_start_ap failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Register AP event callback */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(&amp;ap_eve_callback);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_register_event_callback failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Link Local IPV6 AP address for AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga88dbfc2742725a2c54223740cb27b518">cy_wcm_get_ipv6_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac">CY_WCM_IPV6_LINK_LOCAL</a>, &amp;ipv6_addr);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_ipv6_addr failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    nw_ipv6.ip.v6[0] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0];</div>
<div class="line">    nw_ipv6.ip.v6[1] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1];</div>
<div class="line">    nw_ipv6.ip.v6[2] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2];</div>
<div class="line">    nw_ipv6.ip.v6[3] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3];</div>
<div class="line">    cy_nw_ntoa_ipv6(&amp;nw_ipv6, ip6_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV6 address: %s\n&quot;</span>, ip6_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* wait for 30 seconds for a client to connect */</span></div>
<div class="line">    cy_rtos_delay_milliseconds(30000);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* get connected client */</span></div>
<div class="line">    <a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a> mac_add;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gac2570e24e41dc550252205489f56cc0f">cy_wcm_get_associated_client_list</a>(&amp;mac_add, 1);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_associated_client_list failed....! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(<span class="stringliteral">&quot;mac address obtained from cy_wcm_get_associated_client_list = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">            mac_add[0], mac_add[1], mac_add[2],mac_add[3], mac_add[4], mac_add[5]);</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span>;</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__functions_html_gac2570e24e41dc550252205489f56cc0f"><div class="ttname"><a href="group__group__wcm__functions.html#gac2570e24e41dc550252205489f56cc0f">cy_wcm_get_associated_client_list</a></div><div class="ttdeci">cy_rslt_t cy_wcm_get_associated_client_list(cy_wcm_mac_t *sta_list, uint8_t num_clients)</div><div class="ttdoc">Gets the MAC address of the clients associated with the SoftAP.</div></div>
<div class="ttc" id="agroup__group__wcm__typedefs_html_ga510db2323122294f3956024396ba2ff5"><div class="ttname"><a href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a></div><div class="ttdeci">uint8_t cy_wcm_mac_t[CY_WCM_MAC_ADDR_LEN]</div><div class="ttdoc">Unique 6-byte MAC address represented in network byte order.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:398</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip9"></a>
Snippet 9: AP+STA concurrent mode</h2>
<p >The following snippet demonstrates AP+STA concurrent mode operation.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/* Wi-Fi Credentials: Modify WIFI_SSID and WIFI_PASSWORD to match your Wi-Fi network</span></div>
<div class="line"><span class="comment"> * credentials.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="preprocessor">#define WIFI_SSID                           &quot;SSID&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_PASSWORD                       &quot;PASSWORD&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_SSID_AP                        &quot;AnyCloud&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_KEY_AP                         &quot;abcd@9009&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#define MAX_WIFI_RETRY_COUNT                (3u)</span></div>
<div class="line"><span class="preprocessor">#define WIFI_CONN_RETRY_INTERVAL_MSEC       (100u)</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The size of the cy_wcm_ip_address_t array that is passed to</span></div>
<div class="line"><span class="comment"> * cy_wcm_get_ip_addr API. In the case of stand-alone AP or STA mode, the size of</span></div>
<div class="line"><span class="comment"> * the array is 1. In concurrent AP/STA mode, the size of the array is 2 where</span></div>
<div class="line"><span class="comment"> * the first index stores the IP address of the STA and the second index</span></div>
<div class="line"><span class="comment"> * stores the IP address of the AP.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="structcy__wcm__ip__setting__t.html">cy_wcm_ip_setting_t</a> ap_sta_mode_ip_settings;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> sta_event_callback(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Disconnected from Wi-Fi\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Reconnected to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">/* This event corresponds to the event when the IP address of the device</span></div>
<div class="line"><span class="comment">     * changes.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">        <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %d.%d.%d.%d\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>,</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 8), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 16),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 24));</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fcaa76a9ec3e0ee840982c8094f4416f768">CY_WCM_IP_VER_V6</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %X:%X:%X:%X\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0],</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1]), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2]),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3]));</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> ap_event_callback(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    </div>
<div class="line">    printf(<span class="stringliteral">&quot;######### Received event changed from wcm, event = %d #######\n&quot;</span>, event);</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is down! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Network is up again! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852">CY_WCM_EVENT_CONNECTING</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connecting to AP ... \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f">CY_WCM_EVENT_CONNECTED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connected to AP and network is up !! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5">CY_WCM_EVENT_CONNECT_FAILED</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Connection to AP Failed ! \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a>:</div>
<div class="line">        {</div>
<div class="line">            <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">            <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">            <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">            {</div>
<div class="line">                nw_ipv4.ip.v4 = event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">                cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">                printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line">            }</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa89bf3f175e03aabb5951138e229392c9">CY_WCM_EVENT_STA_JOINED_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which joined = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa54168b9c07156a695d1de5db77f03bcb">CY_WCM_EVENT_STA_LEFT_SOFTAP</a>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;mac address of the STA which left = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[0], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[1], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[2],</div>
<div class="line">                    event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[3], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[4], event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#aa2f4d769a35b7859bf0649d29b5f46a4">sta_mac</a>[5]);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        } </div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Invalid event \n&quot;</span>);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_concurrent_mode()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    <span class="keywordtype">char</span> ip6_str[40];</div>
<div class="line">    <span class="keywordtype">char</span> ip4_str[16];</div>
<div class="line">    <span class="keywordtype">char</span> *ip = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *netmask = <span class="stringliteral">&quot;255.255.255.0&quot;</span>;</div>
<div class="line">    <span class="keywordtype">char</span> *gateway = <span class="stringliteral">&quot;192.168.0.2&quot;</span>;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv4;</div>
<div class="line">    cy_nw_ip_address_t nw_ipv6;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device as a STA.*/</span></div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> config = {.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a864e150cea33f5d4cae3e6834bf56f2e">CY_WCM_INTERFACE_TYPE_AP_STA</a>};</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a> ap_conf;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a> connect_param;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_address,ipv4_addr,ipv6_addr;</div>
<div class="line">    <a class="code hl_enumeration" href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a> security;</div>
<div class="line"> </div>
<div class="line">    memset(&amp;connect_param, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a>));</div>
<div class="line">    memset(&amp;ip_address, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a>));</div>
<div class="line">    memset(&amp;security, 0, <span class="keyword">sizeof</span>(<a class="code hl_enumeration" href="group__group__wcm__enums.html#ga8b22f5a47073d5219440566d0e53e521">cy_wcm_security_t</a>));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID, <span class="keyword">sizeof</span>(WIFI_SSID));</div>
<div class="line">    memcpy(connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_PASSWORD, <span class="keyword">sizeof</span>(WIFI_PASSWORD));</div>
<div class="line">    connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = security;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the Wi-Fi device, Wi-Fi transport, and lwIP network stack.*/</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;config);</div>
<div class="line">    <span class="keywordflow">if</span>(result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_init failed...!\n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* AP settings */</span></div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#gadfcd3cdd92c62bcfd7b0ee53c7e4da7b">cy_wcm_set_ap_ip_setting</a>(&amp;ap_sta_mode_ip_settings, ip, netmask, gateway, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>);</div>
<div class="line">    </div>
<div class="line">    printf(<span class="stringliteral">&quot;\n*** Starting STA Mode ***\n&quot;</span>);</div>
<div class="line">    <span class="comment">/* Attempt to connect to Wi-Fi until a connection is made or</span></div>
<div class="line"><span class="comment">     * MAX_WIFI_RETRY_COUNT attempts have been made.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">for</span> (uint32_t conn_retries = 0; conn_retries &lt; MAX_WIFI_RETRY_COUNT; conn_retries++)</div>
<div class="line">    {</div>
<div class="line">        result = <a class="code hl_function" href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a>(&amp;connect_param, &amp;ip_address);</div>
<div class="line">        <span class="keywordflow">if</span> (result == CY_RSLT_SUCCESS)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;Successfully connected to Wi-Fi network &#39;%s&#39;.\n&quot;</span>, connect_param.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>);</div>
<div class="line"> </div>
<div class="line">            <span class="comment">/* Register event callbacks for changes in the Wi-Fi link status. These</span></div>
<div class="line"><span class="comment">             * events could be related to IP address changes, connection, and</span></div>
<div class="line"><span class="comment">             * disconnection events.</span></div>
<div class="line"><span class="comment">             */</span></div>
<div class="line">            <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(sta_event_callback);</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line"> </div>
<div class="line">        printf(<span class="stringliteral">&quot;Connection to Wi-Fi network failed with error code %d.&quot;</span></div>
<div class="line">                <span class="stringliteral">&quot;Retrying in %d ms...\n&quot;</span>, (<span class="keywordtype">int</span>)result, WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line"> </div>
<div class="line">        cy_rtos_delay_milliseconds(WIFI_CONN_RETRY_INTERVAL_MSEC);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;\n*** Starting AP Mode ***\n&quot;</span>);</div>
<div class="line">    memset(&amp;ap_conf, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ap__config__t.html">cy_wcm_ap_config_t</a>));</div>
<div class="line">    memset(&amp;ipv4_addr, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a>));</div>
<div class="line">    memset(&amp;ipv6_addr, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a>));</div>
<div class="line"> </div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a43adeebc56159fdac2d1e0a19334fb6f">channel</a> = 1;</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_SSID_AP, strlen(WIFI_SSID_AP) + 1);</div>
<div class="line">    memcpy(ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_KEY_AP, strlen(WIFI_KEY_AP) + 1);</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a41b9a70a96b5567416a37661a84b3e7c">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a> = ap_sta_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a> = ap_sta_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a56bf0370a561c858da2008255d0f12bc">netmask</a>;</div>
<div class="line">    ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a> = ap_sta_mode_ip_settings.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#a2e28eec7ae6e6301101991039b5b3bd0">gateway</a>;</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;configured ip address of the AP = %u \n&quot;</span>, (uint8_t)ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>);</div>
<div class="line">    nw_ipv4.ip.v4 = ap_conf.<a class="code hl_variable" href="structcy__wcm__ap__config__t.html#a4d26be457ca32e36d8162c3eb347491b">ip_settings</a>.<a class="code hl_variable" href="structcy__wcm__ip__setting__t.html#aab6aea9cfd72daa55d92f86046e594dd">ip_address</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(&amp;ap_event_callback);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga4b6c66ca0e28ef817bdab02c56d180e6">cy_wcm_start_ap</a>(&amp;ap_conf);</div>
<div class="line">    <span class="keywordflow">if</span> (result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_start_ap failed...! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(<span class="stringliteral">&quot;\nAP started successfully... \n&quot;</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get IPV4 address for AP */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>, &amp;ipv4_addr);</div>
<div class="line">    <span class="keywordflow">if</span> (result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_ip_addr failed...! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(<span class="stringliteral">&quot;\nIPV4 address of AP : &quot;</span>);</div>
<div class="line">    nw_ipv4.ip.v4 = ipv4_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>;</div>
<div class="line">    cy_nw_ntoa(&amp;nw_ipv4, ip4_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV4 address: %s\n&quot;</span>, ip4_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get IPV6 address for AP */</span></div>
<div class="line">    printf(<span class="stringliteral">&quot;Link Local IPV6 AP address \n&quot;</span>);</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga88dbfc2742725a2c54223740cb27b518">cy_wcm_get_ipv6_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a0a2745fb6696e54ad284f17dbad8755f">CY_WCM_INTERFACE_TYPE_AP</a>, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac">CY_WCM_IPV6_LINK_LOCAL</a>, &amp;ipv6_addr);</div>
<div class="line">    <span class="keywordflow">if</span> (result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_ipv6_addr failed...! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(<span class="stringliteral">&quot;\nLink Local IPV6 AP address : &quot;</span>);</div>
<div class="line">    nw_ipv6.ip.v6[0] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0];</div>
<div class="line">    nw_ipv6.ip.v6[1] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1];</div>
<div class="line">    nw_ipv6.ip.v6[2] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2];</div>
<div class="line">    nw_ipv6.ip.v6[3] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3];</div>
<div class="line">    cy_nw_ntoa_ipv6(&amp;nw_ipv6, ip6_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV6 address: %s\n&quot;</span>, ip6_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get Link Local IPV6 STA address */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga88dbfc2742725a2c54223740cb27b518">cy_wcm_get_ipv6_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga04051d082e24439e436a17db75fadfefa635adc564bdb3dbdd71685cef4f470ac">CY_WCM_IPV6_LINK_LOCAL</a>, &amp;ipv6_addr);</div>
<div class="line">    <span class="keywordflow">if</span> (result != CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\ncy_wcm_get_ipv6_addr failed...! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">    printf(<span class="stringliteral">&quot;\nLink Local IPV6 STA address : &quot;</span>);</div>
<div class="line">    nw_ipv6.ip.v6[0] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0];</div>
<div class="line">    nw_ipv6.ip.v6[1] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1];</div>
<div class="line">    nw_ipv6.ip.v6[2] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2];</div>
<div class="line">    nw_ipv6.ip.v6[3] = ipv6_addr.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3];</div>
<div class="line">    cy_nw_ntoa_ipv6(&amp;nw_ipv6, ip6_str);</div>
<div class="line">    printf(<span class="stringliteral">&quot;IPV6 address: %s\n&quot;</span>, ip6_str);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Get MAC address of both STA and AP interface using CY_WCM_INTERFACE_TYPE_AP_STA */</span></div>
<div class="line">    <a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a> *mac_addr_ptr;</div>
<div class="line">    mac_addr_ptr = (<a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a>*)malloc(<span class="keyword">sizeof</span>(<a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a>) *2);</div>
<div class="line">    <a class="code hl_function" href="group__group__wcm__functions.html#ga0f9d3431e34472921e6b89d0a51d1538">cy_wcm_get_mac_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a864e150cea33f5d4cae3e6834bf56f2e">CY_WCM_INTERFACE_TYPE_AP_STA</a>, mac_addr_ptr);</div>
<div class="line">    <a class="code hl_typedef" href="group__group__wcm__typedefs.html#ga510db2323122294f3956024396ba2ff5">cy_wcm_mac_t</a> sta_mac, ap_mac;</div>
<div class="line">    memcpy(&amp;sta_mac, mac_addr_ptr, <span class="keyword">sizeof</span>(sta_mac));</div>
<div class="line">    printf(<span class="stringliteral">&quot;mac address of STA = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">            sta_mac[0], sta_mac[1], sta_mac[2],sta_mac[3], sta_mac[4], sta_mac[5]);</div>
<div class="line">    memcpy(&amp;ap_mac, &amp;mac_addr_ptr[1], <span class="keyword">sizeof</span>(ap_mac));</div>
<div class="line">    printf(<span class="stringliteral">&quot;mac address AP = %02X : %02X : %02X : %02X : %02X : %02X \n&quot;</span>,</div>
<div class="line">            ap_mac[0], ap_mac[1], ap_mac[2],ap_mac[3], ap_mac[4], ap_mac[5]);</div>
<div class="line">    free(mac_addr_ptr);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__enums_html_ggac4c4ca6db8db6efdc3013b789a4c9cf8a864e150cea33f5d4cae3e6834bf56f2e"><div class="ttname"><a href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8a864e150cea33f5d4cae3e6834bf56f2e">CY_WCM_INTERFACE_TYPE_AP_STA</a></div><div class="ttdeci">@ CY_WCM_INTERFACE_TYPE_AP_STA</div><div class="ttdoc">Concurrent AP + STA mode.</div><div class="ttdef"><b>Definition:</b> cy_wcm.h:234</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga0f9d3431e34472921e6b89d0a51d1538"><div class="ttname"><a href="group__group__wcm__functions.html#ga0f9d3431e34472921e6b89d0a51d1538">cy_wcm_get_mac_addr</a></div><div class="ttdeci">cy_rslt_t cy_wcm_get_mac_addr(cy_wcm_interface_t interface_type, cy_wcm_mac_t *mac_addr)</div><div class="ttdoc">Retrieves the MAC address of the given interface.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip10"></a>
Snippet 10: Virtual API usage to check connection status from the secondary core</h2>
<p >The following snippet demonstrates the usage of virtual WCM API - <code><a class="el" href="group__group__wcm__functions.html#ga98c3513c75507fcddb7650b7d20b6f3a" title="Checks if the STA interface is connected to an AP.">cy_wcm_is_connected_to_ap()</a></code> in a multi-core environment.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/***************************** Secondary core ***************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Flag to be set when VCM initialization is completed on the other core */</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">bool</span> is_vcm_init_complete = <span class="keyword">false</span>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Callback registered on the secondary core to handle events from VCM. */</span></div>
<div class="line"><span class="keywordtype">void</span> vcm_callback_sec_core(cy_vcm_event_t event)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> CY_VCM_EVENT_INIT_COMPLETE:</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">/* VCM init complete */</span></div>
<div class="line">            is_vcm_init_complete = 1;</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The following snippet demostrates usage of VCM and virtual WCM APIs from the secondary core. </span></div>
<div class="line"><span class="comment"> * The primary core is where the full WCM implementation is present. The secondary core only</span></div>
<div class="line"><span class="comment"> * has the virtual implementation.</span></div>
<div class="line"><span class="comment"> * In this example, the secondary core application runs first and it enables the primary core.</span></div>
<div class="line"><span class="comment"> * Before enabling the primary core, the secondary core initializes the VCM library.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_virtual_api_usage_sec_core()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    cy_vcm_config_t vcm_config;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the VCM library */</span></div>
<div class="line">    vcm_config.hal_resource_opt = CY_VCM_CREATE_HAL_RESOURCE; <span class="comment">/* set to CY_VCM_CREATE_HAL_RESOURCE as the secondary core is the first one to initialize VCM. */</span></div>
<div class="line">    vcm_config.channel_num = CYHAL_IPC_CHAN_0;</div>
<div class="line">    vcm_config.event_cb = vcm_callback_sec_core;</div>
<div class="line">    result = cy_vcm_init(&amp;vcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_init failed! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Enable the other core. </span></div>
<div class="line"><span class="comment">     * For example, for enabling CM4, the following code is applicable. </span></div>
<div class="line"><span class="comment">     * When this is called, the application on core 2 will begin executing. Ensure cy_vcm_init()</span></div>
<div class="line"><span class="comment">     * is called on the second core when the execution begins.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);</div>
<div class="line">    </div>
<div class="line">    <span class="comment">/* Wait for VCM initialization to complete */</span></div>
<div class="line">    <span class="keywordflow">while</span> ( !is_vcm_init_complete )</div>
<div class="line">    {</div>
<div class="line">        cy_rtos_delay_milliseconds(1000);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the WCM library */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(NULL);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_init failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Check if the device is connected to an AP using the below virtual API */</span></div>
<div class="line">    uint8_t is_connected = <a class="code hl_function" href="group__group__wcm__functions.html#ga98c3513c75507fcddb7650b7d20b6f3a">cy_wcm_is_connected_to_ap</a>();</div>
<div class="line"> </div>
<div class="line">    printf(<span class="stringliteral">&quot;\n STA connection status: %u\n&quot;</span>, is_connected);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* ... */</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* When WCM virtual APIs are no longer needed on the secondary core, deinit WCM and VCM */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga5699a6a4d8f914d86022f3f973916316">cy_wcm_deinit</a>();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_deinit failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    result = cy_vcm_deinit();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_deinit failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/***************************** Primary Core *****************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Wi-Fi Credentials: Modify WIFI_AP_SSID and WIFI_AP_PASSWORD to match your Wi-Fi network</span></div>
<div class="line"><span class="comment"> * credentials.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="preprocessor">#define WIFI_AP_SSID                           &quot;SSID&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_AP_PASSWORD                       &quot;PASSWORD&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Flag that is set when VCM deinit is started by the other core. </span></div>
<div class="line"><span class="comment"> * When this event is received, call cy_vcm_deinit() to deinitialize VCM</span></div>
<div class="line"><span class="comment"> * on the current core.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">bool</span> is_vcm_deinit_requested = <span class="keyword">false</span>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Callback registered by the application on primary core to handle events from VCM. */</span></div>
<div class="line"><span class="keywordtype">void</span> vcm_callback_prim_core(cy_vcm_event_t event)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> CY_VCM_EVENT_DEINIT:</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">/* The other core has initiated VCM deinit. Deinitialize VCM locally. */</span></div>
<div class="line">            is_vcm_deinit_requested = <span class="keyword">true</span>;</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The following snippet demostrates usage of VCM on the primary core. </span></div>
<div class="line"><span class="comment"> * The primary core is where the full WCM implementation is present. The secondary core only</span></div>
<div class="line"><span class="comment"> * has the virtual implementation. The primary core initializes wcm and connects to an AP.</span></div>
<div class="line"><span class="comment"> * Ensure that this snippet is executed when the primary core is enabled.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_virtual_api_usage_prim_core()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    cy_vcm_config_t vcm_config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> wcm_config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a> connect_params;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the VCM library */</span></div>
<div class="line">    vcm_config.hal_resource_opt = CY_VCM_USE_HAL_RESOURCE; <span class="comment">/* set to CY_VCM_USE_HAL_RESOURCE as primary core initializes VCM after the secondary core. */</span></div>
<div class="line">    vcm_config.channel_num = CYHAL_IPC_CHAN_0;</div>
<div class="line">    vcm_config.event_cb = vcm_callback_prim_core;</div>
<div class="line">    result = cy_vcm_init(&amp;vcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_init failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the WCM library */</span></div>
<div class="line">    wcm_config.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;wcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_init failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Connect to Wi-Fi */</span></div>
<div class="line">    memset(&amp;connect_params, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a>));</div>
<div class="line">    memcpy(connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_AP_SSID, strlen(WIFI_AP_SSID) + 1);</div>
<div class="line">    memcpy(connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_AP_PASSWORD, strlen(WIFI_AP_PASSWORD) + 1);</div>
<div class="line">    connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a>(&amp;connect_params, &amp;ip_addr);</div>
<div class="line">    <span class="keywordflow">if</span>(result == CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Connect successful!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Wait for VCM deinit on the other core. When deinit event is received,</span></div>
<div class="line"><span class="comment">     * deinitialize the VCM library on this core. */</span></div>
<div class="line">    <span class="keywordflow">while</span>( !is_vcm_deinit_requested )</div>
<div class="line">    {</div>
<div class="line">        cy_rtos_delay_milliseconds(1000);</div>
<div class="line">    }</div>
<div class="line">    </div>
<div class="line">    <span class="comment">/* VCM deinit event received. */</span></div>
<div class="line">    result = cy_vcm_deinit();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_deinit failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* If WCM is no longer needed, deinitialize WCM. */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga5699a6a4d8f914d86022f3f973916316">cy_wcm_deinit</a>();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_deinit failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga5699a6a4d8f914d86022f3f973916316"><div class="ttname"><a href="group__group__wcm__functions.html#ga5699a6a4d8f914d86022f3f973916316">cy_wcm_deinit</a></div><div class="ttdeci">cy_rslt_t cy_wcm_deinit(void)</div><div class="ttdoc">Shuts down the WCM.</div></div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga98c3513c75507fcddb7650b7d20b6f3a"><div class="ttname"><a href="group__group__wcm__functions.html#ga98c3513c75507fcddb7650b7d20b6f3a">cy_wcm_is_connected_to_ap</a></div><div class="ttdeci">uint8_t cy_wcm_is_connected_to_ap(void)</div><div class="ttdoc">Checks if the STA interface is connected to an AP.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="snip11"></a>
Snippet 11: Virtual API usage to register for WCM events from the secondary core</h2>
<p >The following snippet demonstrates the usage of virtual WCM API - <code><a class="el" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6" title="Registers an event callback to monitor the connection and IP address change events.">cy_wcm_register_event_callback()</a></code> and <code><a class="el" href="group__group__wcm__functions.html#ga957a1964b1a2bf191266ee3e60549b9e" title="De-registers an event callback.">cy_wcm_deregister_event_callback()</a></code> in a multi-core environment.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="comment">/***************************** Secondary core ***************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Flag to be set when VCM initialization is completed on the other core */</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">bool</span> is_vcm_init_complete_2 = <span class="keyword">false</span>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Callback registered on the secondary core to handle events from VCM. */</span></div>
<div class="line"><span class="keywordtype">void</span> vcm_callback_sec_core_2(cy_vcm_event_t event)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> CY_VCM_EVENT_INIT_COMPLETE:</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">/* VCM init complete */</span></div>
<div class="line">            is_vcm_init_complete_2 = 1;</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> event_callback_sec_core_2(<a class="code hl_enumeration" href="group__group__wcm__enums.html#gafada6a09a78bd0473f3daef54621567f">cy_wcm_event_t</a> event, <a class="code hl_union" href="unioncy__wcm__event__data__t.html">cy_wcm_event_data_t</a> *event_data)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa206d74c35be5bf29e7903367287efc79">CY_WCM_EVENT_DISCONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Disconnected from Wi-Fi\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fab2e59655829c24bd5d0ea68622c8c56e">CY_WCM_EVENT_RECONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Reconnected to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="comment">/* This event corresponds to the event when the IP address of the device</span></div>
<div class="line"><span class="comment">     * changes.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafe83442aa63aa747c3025d0874482c86">CY_WCM_EVENT_IP_CHANGED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line">        <a class="code hl_function" href="group__group__wcm__functions.html#gad15fb09ca84b85997b967c3a22f9676c">cy_wcm_get_ip_addr</a>(<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>, &amp;ip_addr);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fca579126d4304962b6ee0f286e5afcbe8a">CY_WCM_IP_VER_V4</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %d.%d.%d.%d\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a>,</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 8), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 16),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#acabea09ec2785e76f7d867a74dd6afd7">v4</a> &gt;&gt; 24));</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span>(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a7c275791b147e4ccd77ad178dd25bf81">version</a> == <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga24d3def17207a3c64b62fb4b8a44a7fcaa76a9ec3e0ee840982c8094f4416f768">CY_WCM_IP_VER_V6</a>)</div>
<div class="line">        {</div>
<div class="line">            printf(<span class="stringliteral">&quot;IP Address: %X:%X:%X:%X\n&quot;</span>, (uint8_t)event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[0],</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[1]), (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[2]),</div>
<div class="line">                   (uint8_t)(event_data-&gt;<a class="code hl_variable" href="unioncy__wcm__event__data__t.html#a9c8f9a98e351394d704d1796328ae466">ip_addr</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a86c6e6f9182502683675c0656a3ad088">ip</a>.<a class="code hl_variable" href="structcy__wcm__ip__address__t.html#a969244fd2e8b1da5fc07b75c4811e33c">v6</a>[3]));</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa683d1014dce666536998f4d185975852">CY_WCM_EVENT_CONNECTING</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Connecting to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fa3cb25ea52d7dfe04a55193c5289d501f">CY_WCM_EVENT_CONNECTED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Connected to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggafada6a09a78bd0473f3daef54621567fafa85fe7467f303e5425b54a8f20072e5">CY_WCM_EVENT_CONNECT_FAILED</a> == event)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Failed to connect to Wi-Fi.\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The following snippet demostrates usage of VCM and virtual WCM APIs from the secondary core. </span></div>
<div class="line"><span class="comment"> * The primary core is where the full WCM implementation is present. The secondary core only</span></div>
<div class="line"><span class="comment"> * has the virtual implementation.</span></div>
<div class="line"><span class="comment"> * In this example, the secondary core application runs first and it enables the primary core.</span></div>
<div class="line"><span class="comment"> * Before enabling the primary core, the secondary core initializes VCM library.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_virtual_api_usage_sec_core_2()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    cy_vcm_config_t vcm_config;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the VCM library */</span></div>
<div class="line">    vcm_config.hal_resource_opt = CY_VCM_CREATE_HAL_RESOURCE; <span class="comment">/* set to CY_VCM_CREATE_HAL_RESOURCE as the secondary core is the first one to initialize VCM. */</span></div>
<div class="line">    vcm_config.channel_num = CYHAL_IPC_CHAN_0;</div>
<div class="line">    vcm_config.event_cb = vcm_callback_sec_core_2;</div>
<div class="line">    result = cy_vcm_init(&amp;vcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_init failed! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Enable the other core. </span></div>
<div class="line"><span class="comment">     * For example, for enabling CM4, the following code is applicable. </span></div>
<div class="line"><span class="comment">     * When this is called, the application on core 2 will begin executing. Ensure cy_vcm_init()</span></div>
<div class="line"><span class="comment">     * is called on the second core when the execution begins.</span></div>
<div class="line"><span class="comment">     */</span></div>
<div class="line">    Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);</div>
<div class="line">    </div>
<div class="line">    <span class="comment">/* Wait for VCM initialization to complete */</span></div>
<div class="line">    <span class="keywordflow">while</span> ( !is_vcm_init_complete )</div>
<div class="line">    {</div>
<div class="line">        cy_rtos_delay_milliseconds(1000);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the WCM library */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(NULL);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_init failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Listen for changes in the AP connection by registering event callback */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga02f205b4d522c99d6c0b48f15683b0b6">cy_wcm_register_event_callback</a>(event_callback_sec_core_2);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_register_event_callback failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* ... */</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* When no longer needed, deregister callback for WCM events */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga957a1964b1a2bf191266ee3e60549b9e">cy_wcm_deregister_event_callback</a>(event_callback_sec_core_2);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_deregister_event_callback failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* When WCM virtual APIs are no longer needed on the secondary core, deinit WCM and VCM */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga5699a6a4d8f914d86022f3f973916316">cy_wcm_deinit</a>();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_deinit failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    result = cy_vcm_deinit();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_deinit failed on secondary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/***************************** Primary Core *****************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Wi-Fi Credentials: Modify WIFI_AP_SSID and WIFI_AP_PASSWORD to match your Wi-Fi network</span></div>
<div class="line"><span class="comment"> * credentials.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="preprocessor">#define WIFI_AP_SSID                           &quot;SSID&quot;</span></div>
<div class="line"><span class="preprocessor">#define WIFI_AP_PASSWORD                       &quot;PASSWORD&quot;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Flag that is set when VCM deinit is started by the other core. </span></div>
<div class="line"><span class="comment"> * When this event is received, call cy_vcm_deinit() to deinitialize VCM</span></div>
<div class="line"><span class="comment"> * on the current core.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">bool</span> is_vcm_deinit_requested_2 = <span class="keyword">false</span>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* Callback registered by the application on primary core to handle events from VCM. */</span></div>
<div class="line"><span class="keywordtype">void</span> vcm_callback_prim_core_2(cy_vcm_event_t event)</div>
<div class="line">{</div>
<div class="line">    <span class="keywordflow">switch</span>(event)</div>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">case</span> CY_VCM_EVENT_DEINIT:</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">/* The other core has initiated VCM deinit. Deinitialize VCM locally. */</span></div>
<div class="line">            is_vcm_deinit_requested_2 = <span class="keyword">true</span>;</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">        <span class="keywordflow">default</span>:</div>
<div class="line">            <span class="keywordflow">break</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">/* The following snippet demostrates usage of VCM on the primary core. </span></div>
<div class="line"><span class="comment"> * The primary core is where the full WCM implementation is present. The secondary core only</span></div>
<div class="line"><span class="comment"> * has the virtual implementation. The primary core initializes wcm and connects to an AP.</span></div>
<div class="line"><span class="comment"> * Ensure that this snippet is executed when the primary core is enabled.</span></div>
<div class="line"><span class="comment"> */</span></div>
<div class="line"><span class="keywordtype">void</span> snippet_wcm_virtual_api_usage_prim_core_2()</div>
<div class="line">{</div>
<div class="line">    cy_rslt_t result;</div>
<div class="line">    cy_vcm_config_t vcm_config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__config__t.html">cy_wcm_config_t</a> wcm_config;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a> connect_params;</div>
<div class="line">    <a class="code hl_struct" href="structcy__wcm__ip__address__t.html">cy_wcm_ip_address_t</a> ip_addr;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the VCM library */</span></div>
<div class="line">    vcm_config.hal_resource_opt = CY_VCM_USE_HAL_RESOURCE; <span class="comment">/* set to CY_VCM_USE_HAL_RESOURCE as primary core initializes VCM after the secondary core. */</span></div>
<div class="line">    vcm_config.channel_num = CYHAL_IPC_CHAN_0;</div>
<div class="line">    vcm_config.event_cb = vcm_callback_prim_core_2;</div>
<div class="line">    result = cy_vcm_init(&amp;vcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_init failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Initialize the WCM library */</span></div>
<div class="line">    wcm_config.<a class="code hl_variable" href="structcy__wcm__config__t.html#ab516902a377cf7b51d1965183c0bfc2f">interface</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#ggac4c4ca6db8db6efdc3013b789a4c9cf8ae93c4aa9ce482c333a23bdc535df3208">CY_WCM_INTERFACE_TYPE_STA</a>;</div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga888428a2325f131528f7447e894002eb">cy_wcm_init</a>(&amp;wcm_config);</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_init failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Connect to Wi-Fi */</span></div>
<div class="line">    memset(&amp;connect_params, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcy__wcm__connect__params__t.html">cy_wcm_connect_params_t</a>));</div>
<div class="line">    memcpy(connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#aefb4693ca1fa808349032561a2e4b3bc">SSID</a>, WIFI_AP_SSID, strlen(WIFI_AP_SSID) + 1);</div>
<div class="line">    memcpy(connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#ad9ba797a8bc9bcb7708eb9b4560e3095">password</a>, WIFI_AP_PASSWORD, strlen(WIFI_AP_PASSWORD) + 1);</div>
<div class="line">    connect_params.<a class="code hl_variable" href="structcy__wcm__connect__params__t.html#add927d1d5bbaf348296daad9a6312023">ap_credentials</a>.<a class="code hl_variable" href="structcy__wcm__ap__credentials__t.html#a576fbc5a934d7efe6c98e265678c38d9">security</a> = <a class="code hl_enumvalue" href="group__group__wcm__enums.html#gga8b22f5a47073d5219440566d0e53e521a772f5ab0cd577a4d8f9426be3123cefe">CY_WCM_SECURITY_WPA2_AES_PSK</a>;</div>
<div class="line"> </div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga0aae35b5ae477a1a10caccf937beff0d">cy_wcm_connect_ap</a>(&amp;connect_params, &amp;ip_addr);</div>
<div class="line">    <span class="keywordflow">if</span>(result == CY_RSLT_SUCCESS)</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;Connect successful!\n&quot;</span>);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Wait for VCM deinit on the other core. When deinit event is received,</span></div>
<div class="line"><span class="comment">     * deinitialize the VCM library on this core. */</span></div>
<div class="line">    <span class="keywordflow">while</span>( !is_vcm_deinit_requested_2 )</div>
<div class="line">    {</div>
<div class="line">        cy_rtos_delay_milliseconds(1000);</div>
<div class="line">    }</div>
<div class="line">    </div>
<div class="line">    <span class="comment">/* VCM deinit event received. */</span></div>
<div class="line">    result = cy_vcm_deinit();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_vcm_deinit failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* If WCM is no longer needed, deinitialize WCM. */</span></div>
<div class="line">    result = <a class="code hl_function" href="group__group__wcm__functions.html#ga5699a6a4d8f914d86022f3f973916316">cy_wcm_deinit</a>();</div>
<div class="line">    <span class="keywordflow">if</span>( result != CY_RSLT_SUCCESS )</div>
<div class="line">    {</div>
<div class="line">        printf(<span class="stringliteral">&quot;\n cy_wcm_deinit failed on primary core! \n&quot;</span>);</div>
<div class="line">        <span class="keywordflow">return</span>;</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__wcm__functions_html_ga957a1964b1a2bf191266ee3e60549b9e"><div class="ttname"><a href="group__group__wcm__functions.html#ga957a1964b1a2bf191266ee3e60549b9e">cy_wcm_deregister_event_callback</a></div><div class="ttdeci">cy_rslt_t cy_wcm_deregister_event_callback(cy_wcm_event_callback_t event_callback)</div><div class="ttdoc">De-registers an event callback.</div></div>
</div><!-- fragment --> </div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Wi-Fi Connection Manager Library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
</body>
</html>
